【发布时间】:2023-03-15 18:03:01
【问题描述】:
我有一个使用 Google Plus API 的 android 应用程序,我还要求提供一个访问令牌,我将其传递给我的服务器,以便我可以调用 oauth 2.0 API 来获取用户详细信息。
我要求使用GoogleAuthUtil.getToken 的访问令牌,其范围如下:
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 范围突然丢失。有没有想过为什么有时会发生这种情况?
【问题讨论】:
标签: android oauth-2.0 google-plus