我有一個使用Google Plus API的Android應用程序,我還要求提供一個訪問令牌,我將它傳遞給我的服務器,以便我可以使oauth 2.0 API調用獲取用戶詳細信息。 我要求使用GoogleAuthUtil.getToken
具有以下範圍的訪問令牌:GoogleAuth訪問令牌缺少userinfo.profile範圍
String scopes = "oauth2: https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/plus.login" ;
然後,我通過訪問令牌我到我的服務器,並進行API調用:https://www.googleapis.com/oauth2/v2/userinfo
返回以下用戶的詳細信息: [id, email, verified, name, given_name, family_name, link, picture, gender, locale]
迄今爲止這麼好。 這工作90%的時間。最近我一直在吸引那些沒有大部分細節的用戶。當我審視自己的訪問令牌我看到以下內容:
{
"issued_to": "534771845378-a8epgha85s5hkr3bqnsj8ihjvpl8pms.apps.googleusercontent.com",
"audience": "534771845378-ha8epgha85s5hkr3bqnsj8ihjvpl8pms.apps.googleusercontent.com",
"user_id": "103098746579631883577",
"scope": "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email",
"expires_in": 3382,
"email": "***@***.com",
"verified_email": true,
"access_type": "offline"
}
注意,userinfo.profile範圍突然失蹤。任何想法爲什麼這可能發生在場合?
聽起來正確。謝謝! – OferM