import json


def getToken(response):
    """
    Get the tokenised card reference from the API response
    :param response: Response object in JSON
    :return: String - token
    """

    resp_dict = json.loads(response.text)

    try:
        token = resp_dict["token"]
    except KeyError:
        print('Retrieval unsuccessful.')
        return None

    return token