def parse_token_response(body, scope=None):
    try:
        params = json.loads(body)
    except ValueError:

        # Fall back to URL-encoded string, to support old implementations,
        # including (at time of writing) Facebook. See:
        #   https://github.com/idan/oauthlib/issues/267

        params = dict(urlparse.parse_qsl(body))
        for key in ('expires_in', 'expires'):
            if key in params:  # cast a couple things to int
                params[key] = int(params[key])

    if 'scope' in params:
        params['scope'] = scope_to_list(params['scope'])

    if 'expires' in params:
        params['expires_in'] = params.pop('expires')

    if 'expires_in' in params:
        params['expires_at'] = time.time() + int(params['expires_in'])

    params = OAuth2Token(params, old_scope=scope)
    validate_token_parameters(params)
    return params
Parse the JSON token response body into a dict.
dataset/ETHPy150Open idan/oauthlib/oauthlib/oauth2/rfc6749/parameters.py/parse_token_response