Google Oauth2 userinfo API未返回用户名数据 [英] Google Oauth2 userinfo API not returning user's name data
问题描述
在过去的几个月中,我在使用OAuth登录后一直使用此网址来检索用户的名称和信息.
For the past couple months I have been using this url to retrieve a user's name and info after logging in with OAuth.
https://www.googleapis.com/oauth2/v1/userinfo?alt=json
这给了我以下格式的JSON:
This gave me JSON in the following format:
{
"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:
This morning, when my app hit this endpoint, it got JSON in the following format:
{
"id": "12345",
"email": "name@gmail.com",
"verified_email": true,
"picture": "https://lh3.googleusercontent.com/123/photo.jpg"
}
我尚未在开发人员控制台中对配置进行任何更改.有谁知道造成这个问题的原因是什么?
I have not made any changes to the configuration in the developer console. Does anyone know what the cause of this problem could be?
推荐答案
我认为您应该使用不同的URL-来自OpenID Connect的URL,它是用于身份验证的OAuth2扩展,在中指定了userinfo
终结点href ="https://openid.net/specs/openid-connect-core-1_0.html#UserInfo" rel ="nofollow noreferrer">其RFC .
I think you should use a different URL - the one from OpenID Connect, which is an OAuth2 extension for authentication and the userinfo
endpoint is specified in its RFC.
https://openidconnect.googleapis.com/v1/userinfo
The correct procedure is to get this URL from the OpenID Discovery document (Google doc)
https://accounts.google.com/.well-known/openid-configuration
及其userinfo_endpoint
属性.
您一直在使用的端点的行为更改可能与Google+被关闭有关.但这只是我的猜测.
The change of behavior of the endpoint you have been using may have something to do with Google+ being shut down. But that's just my guess.
这篇关于Google Oauth2 userinfo API未返回用户名数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!