在过去的几个月里,我一直在使用这个 url 在使用 OAuth 登录后检索用户的姓名和信息。
https://www.googleapis.com/oauth2/v1/userinfo?alt=json
这给了我以下格式的 JSON:
{
"id": "12345",
"email": "name@gmail.com",
"verified_email": true,
"name": "First Last",
"given_name": "First",
"family_name": "Last",
"link": "https://plus.google.com/12345",
"picture": "https://lh3.googleusercontent.com/123photo.jpg",
"locale": "en"
}
今天早上,当我的应用到达此端点时,它获得了以下格式的 JSON:
{
"id": "12345",
"email": "name@gmail.com",
"verified_email": true,
"picture": "https://lh3.googleusercontent.com/123/photo.jpg"
}
我没有对开发者控制台中的配置进行任何更改。有谁知道这个问题的原因可能是什么?
最佳答案
我认为您应该使用不同的 URL - 来自 OpenID Connect 的 URL,它是用于身份验证的 OAuth2 扩展,userinfo
端点在 its RFC 中指定。 .
https://openidconnect.googleapis.com/v1/userinfo
正确的步骤是从 OpenID Discovery 中获取此 URL文档 ( Google doc )
https://accounts.google.com/.well-known/openid-configuration
及其 userinfo_endpoint
属性。
您一直在使用的端点的行为变化可能与 Google+ 被关闭有关。但这只是我的猜测。
关于api - Google Oauth2 userinfo API 不返回用户名数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55541686/