8

I'm using spring-social/spring-social-github in order to authenticate user through GitHub in my Spring Boot web application.

In order to sign in user I have created following html form:

<form action="http://example.com/auth/github" method="POST">
 <input name="scope" value="user,gist" type="hidden">
 <button type="submit">Sign in with GitHub</button>
</form>

everything works fine except I can't get user email address.

According to GitHub documentation GitHub OAuth API user scope includes user:email and user:follow.

What can be wrong ?

UPDATED

After talking with GitHub support I have more information on this one:

The problem is that this library uses following https://api.github.com/user endpoint in order to get user profile. That endpoint returns the public email address for the user, and users don't need to specify a public email address. So, if the user doesn't have a public email address defined -- you get a null value back.

The https://api.github.com/user/emails endpoint returns the private list of email addresses and that list should always have at least one address.

if it possible to extend spring-social-github library in order to call https://api.github.com/user/emails endpoint for user email address ?

Right now I'm unable to override GitHubTemplate.initSubApis() in order to initialize my own version of UserTemplate.getUserProfile() because GitHub Template.initSubApis is a private method..

I have created issue on GitHub for spring-social-github can't get user email

alexanoid
  • 24,051
  • 54
  • 210
  • 410

0 Answers0