ueberauth / ueberauth_google

Google OAuth2 Strategy for Überauth.
MIT License
166 stars 85 forks source link

Use the OpenID endpoint to get user profile info #14

Closed jochakovsky closed 8 years ago

jochakovsky commented 8 years ago

See discussion in #9. This new endpoint for obtaining user information returns almost the same information as the old endpoint, but does not require turning on the Google+ API. This follows the OpenID Connect directions at https://developers.google.com/identity/protocols/OpenIDConnect#obtaininguserprofileinformation instead of the Google Sign-In directions.

When testing with my Google account, I found a couple of very minor differences in the bodies of the responses from these two endpoints:

  1. The current endpoint returns a picture URL with a sz=50 query string, which links to a small photo. The OpenID endpoint returns the same URL but with no query string, which links to a large version of the same photo.
  2. The current endpoint contains "kind" => "plus#personOpenIdConnect",, and the new OpenID endpoint omits this field.

I also renamed @token_url to avoid confusion with https://github.com/ueberauth/ueberauth_google/blob/master/lib/ueberauth/strategy/google/oauth.ex#L17. @token_url was actually not a URL for exchanging an authorization code for an access token, as the variable name implied. Instead, it was just an endpoint to retrieve user info once already authenticated with Google.

doomspork commented 8 years ago

Fantastic! Thank you @jochakovsky, I will release a new version later today.