user12125591
user12125591

Reputation: 83

Google OAuth with profile in scope missing name

I have an issue with Google OAuth2 in my web application. I created client_id in the Google console and set scope to "openid email profile" in the url:

https://accounts.google.com/o/oauth2/auth/oauthchooseaccount?redirect_uri=MY_REDIRECT_URL&response_type=id_token&scope=email+profile+openid&client_id=MY_CLIENT_ID

After successful login Google redirects me to my URL with id_token. But when I validate this token on the backend the token is valid but in the response the "name" field is missing.

Upvotes: 2

Views: 1641

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116968

Google doesn't always return the claims you would expect. With open id connect. Also there is no guarantee that a user has even added a name.

If you are trying to get a users profile information you should use People.get. This is the best and most reliable way to get user profile information.

Don't rely on the claims.

Upvotes: 1

Related Questions