Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get user profile #9

Closed
SimonLab opened this issue Nov 20, 2019 · 3 comments
Closed

Get user profile #9

SimonLab opened this issue Nov 20, 2019 · 3 comments
Assignees

Comments

@SimonLab
Copy link
Member

Google Plus API is now deprecated:
image

After a while trying to find the documenatation I think the new endpoint to get the user profile is:
https://www.googleapis.com/oauth2/v3/userinfo?access_token=...

You don't need to enable other API on the Google console.
I've manage to get my user info directly via the browser, however I've got some error while parsing the response with Poison (I thin the request returned an error).
I'm going to check if the request needs specific headers to work

@SimonLab
Copy link
Member Author

Getting the user information:
image

The mix dependency wasn't up to date!

@SimonLab
Copy link
Member Author

SimonLab commented Nov 27, 2019

The information available are defined by the scopes which can be
profile returns family_name, given_name, name, picture, sub
email returns email, email_verified, picture, sub
openid returns picture, sub

(I've tested the returns value manually by inspecting the returned values so maybe more information can be displayed?)

see https://developers.google.com/identity/protocols/googlescopes#google_sign-in
image

You can combine scopes by adding space between them, for example if you want to get the profile information and the email information you can use the scope profile email.

The scope value is used to create the Google authentication url and will define which information will be accessible:

def generate_oauth_url do
client_id = Application.get_env(:elixir_auth_google, :google_client_id)
scope = Application.get_env(:elixir_auth_google, :google_scope ) || "profile"
redirect_uri = Application.get_env(:elixir_auth_google, :google_redirect_uri)
"#{@google_auth_url}&client_id=#{client_id}&scope=#{scope}&redirect_uri=#{redirect_uri}"

@nelsonic
Copy link
Member

nelsonic commented Dec 5, 2019

@SimonLab looks good. thanks. 👍

@nelsonic nelsonic closed this as completed Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants