walkingtaco
walkingtaco

Reputation: 61

Google Oauth2 userinfo API not returning user's name data

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": "[email protected]",
      "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": "[email protected]",
      "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?

Upvotes: 3

Views: 2168

Answers (1)

Ján Halaša
Ján Halaša

Reputation: 8421

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.

Upvotes: 1

Related Questions