1
我正在嘗試使用Google OAuth2獲取用戶的聯繫信息。我不努力獲得訪問權限,我想知道由於某種原因,我已經停止獲取refresh_token
,而是獲得id_token
(長JWT字符串)。 我使用python urllib
來檢索用戶的訪問信息。我的代碼是:google oauth2 id_token vs refresh_token
scope = 'https://accounts.google.com/o/oauth2/token'
params = urllib.urlencode({
'code': request.GET['code'],
'redirect_uri': settings.SOCIAL_AUTH_GOOGLE_REDIRECT_URI,
'client_id': settings.SOCIAL_AUTH_GOOGLE_OAUTH2_KEY,
'client_secret': settings.SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET,
'grant_type': 'authorization_code',
})
響應:
{u'access_token': u'hash',
u'token_type': u'Bearer',
u'expires_in': 3600,
u'id_token': u'really long hash'}
我用的接觸範圍https://www.google.com/m8/feeds/contacts/default/full?alt=json
當我試圖添加到PARAMS access_type : offline
我得到的錯誤如下:
Failed to retrive access_token. Status: 400
Message: {
"error" : "invalid_request",
"error_description" : "Parameter not allowed for this message type: access_type"
}
所以之後,我想知道:
- 我可以使用
id_token
刷新我的access_token
? - 如果第一個是
True
:如何? - 是否有類型誰是得到驗證的用戶之間的任何差別,因爲我注意到,有時你
refresh_token
,但我需要永久得到它,下一次我做一個OAuth2流程,我得到id_token