Skip to content
New issue

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

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

Already on GitHub? # to your account

Cannot get the private email from Github API #28

Open
lethuydung0109 opened this issue Apr 14, 2020 · 3 comments
Open

Cannot get the private email from Github API #28

lethuydung0109 opened this issue Apr 14, 2020 · 3 comments

Comments

@lethuydung0109
Copy link

Hello, I followed your code and I have a problem of getting email address after authenticating successfully against Github. The problem is that Github only provides us the public email address which is normally null by default.

To take the private emails, we should call API /user/emails with access token taken from the earlier authentication. However, I don't know how to retrieve that access token.

Do you have any suggestion?

@luvarqpp
Copy link

If I am not wrong, only id attribute is mandatory. name, email and avatar_url can be null.

In your github account have a look at personal settings and email part. There is some tunable as:

IMHO you should only use the id attribute to identify github authorized users. Optional fields are only nice things to pre-populate user profile in your application.

@lethuydung0109
Copy link
Author

What a nice suggestion @luvarqpp ! Thank you for this :D I'll try this way.

By the way, do you know how to retrieve the Access Token sent to us?

Thank you in advance,
Dung

@luvarqpp
Copy link

@lethuydung0109 it is a bit longer topic... OAuth does claim that some user has been authenticated by sending some info to your OAuth2AuthenticationSuccessHandler class, which does have TokenProvider, see

Given class does generate Authorization (Bearer) token for your application and this token (fully in your hands => you can encode in token for example shopping list of currently logged user if you need) is than used for authentication.

I can recommend you to have a look at some "deep dive" videos, like this one: https://www.youtube.com/watch?v=8rnOsF3RVQc

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants