import requests


def credentials_response(credential):
    """
    Make a request to the charmetric api for the access token and
    return the text of the response.
    """
    authURL = f"https://api.chartmetric.com/api/token"
    headers = {
        "Content-Type": "application/json",
    }
    refreshtokenkey = "refreshtoken"
    refreshtoken = credential[refreshtokenkey]
    data = "{" + f'"{refreshtokenkey}":"{refreshtoken}"' + "}"

    response = requests.post(authURL, headers=headers, data=data)

    if not response.ok:  # raise if issue
        response.raise_for_status()
    return response.text