问题
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
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"
}
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?
回答1:
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
and its userinfo_endpoint
attribute.
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.
来源:https://stackoverflow.com/questions/55541686/google-oauth2-userinfo-api-not-returning-users-name-data