2013-09-24 52 views
0

我有一個使用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範圍突然失蹤。任何想法爲什麼這可能發生在場合?

回答

1

這可能是因爲越來越多的信息存儲在具有不同訪問控制的Google+個人資料中,而不是舊的用戶個人資料。

你可以使用該https://www.googleapis.com/plus/v1/people/me端點plus.login範圍的公開個人資料信息,但如果他們取得了他們的信息公開,這隻會是。您也將無法使用此端點獲得他們的電子郵件 - 您仍然需要使用oauth userinfo端點。

查看https://developers.google.com/+/api/latest/瞭解更多詳情和其他可用端點。

+1

聽起來正確。謝謝! – OferM