requests-oauthlib
requests-oauthlib copied to clipboard
Can't get id_token in google oauth token
google = OAuth2Session(client_id, redirect_uri=redirect_uri)
token = google.fetch_token(token_url, client_secret=client_secret,
authorization_response=google_response)
Google returns a token, that looks(prints) like this:
{u'token_type': u'Bearer', u'refresh_token': u'1/sdfsdfsfd, u'access_token': u'sdfsdfsfdsfdsfd', u'id_token': u'sdffsdfsdfsdfsdf', u'expires_in': 3600, u'expires_at': 1425417341.962704}
But I can't access the id_token. token.keys() returns [u'access_token', u'token_type', u'expires_in', u'refresh_token', u'expires_at']
Why is it like that? Is this the intended behavior?
I realize this is an old issue, however today I encountered the same. google-auth however tries to obtain the id_token from the session to return credentials, which is always none. Am I doing something wrong and is the id token removed on purpose?
It appears that the credentials are parsed using the parse_token_response()
function in oauthlib
, which is only looking for certain values in the response. Any other values are ignored. I'm not sure the best way to fix this -- you might need to use a compliance hook to get that id_token
value.