我正在编写一个简单的逻辑,以使用Google Photos REST API列出图片。我希望在连接的用户个人资料登录到我的应用程序后立即进行打印。但是我无法在REST API中找到任何端点来获取用户个人资料,就像在Gmail或Drive REST API中一样。
https://developers.google.com/photos/library/guides/get-started#request-id
同时,我尝试从oAuth2访问令牌中获取用户详细信息,但是它没有提供任何用户详细信息,例如邮件ID或名称。
GET https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=ACCESS_TOKEN
响应:
{
"issued_to": "xxxxx.apps.googleusercontent.com",
"audience": "xxxxxx.apps.googleusercontent.com",
"scope": "https://www.googleapis.com/auth/photoslibrary",
"expires_in": 3522,
"access_type": "offline"
}
有什么方法可以从上述oAuth2 access_token(与范围无关)中检索用户个人资料?
恐怕目前无法实现。oAuth2令牌不包含用户的电子邮件。通过Google API获取用户电子邮件的唯一方法是允许https://www.googleapis.com/auth/userinfo.email
范围,并使用oAuth2 API或People API。您可以使用的呼叫可能是以下任何一种:
得到 https://www.googleapis.com/oauth2/v2/userinfo
得到 https://www.googleapis.com/userinfo/v2/me
得到 https://www.googleapis.com/plus/v1/people/me
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句