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

email is nil when authenticating using github app credentials #41

Closed
antonydenyer opened this issue Feb 27, 2018 · 12 comments · Fixed by #42
Closed

email is nil when authenticating using github app credentials #41

antonydenyer opened this issue Feb 27, 2018 · 12 comments · Fixed by #42

Comments

@antonydenyer
Copy link
Contributor

If you are using credentials for a github app you may not have access to the user's email address. Scopes are redundant as they are defined in your application settings as opposed to the oauth request.

identifying-users-on-your-site

What are the options we have here? Have an additional config setting to allow nil?

@antonydenyer antonydenyer changed the title email is nil when authenticating using a github app email is nil when authenticating using github app credentials Feb 27, 2018
@moroz
Copy link

moroz commented Feb 28, 2018

Upping this. I am following "The Complete Elixir and Phoenix Bootcamp" on Udemy and currently I can't proceed with the development, getting "Unable to access the user's email address" error with every attempt to log in.
As my knowledge of Elixir is still very basic, I can't offer to fix this issue as yet.
Edit: I temporarily fixed this by setting a public e-mail address in my Github profile, but I still think the authentication shouldn't break just because the user has no e-mail!

@antonydenyer
Copy link
Contributor Author

Added an option to fix the issue in #42

@sbruhns
Copy link

sbruhns commented Jun 28, 2018

@moroz I also run into this issue while following "The Complete Elixir and Phoenix Bootcamp". I solved this by setting explicit default scopes in config.ex. Also I used the version 0.7 instead of the old 0.4 used in this guide.

config :ueberauth, Ueberauth,
  providers: [
    github: { Ueberauth.Strategy.Github, [default_scope: "user,public_repo"]}
  ]

@natseg
Copy link

natseg commented Jul 11, 2018

@sbruhns That did not do the trick for me.

@jakecurreri
Copy link

Make sure your Github email address is set to public (if it's private, you'll continue to see an error message).

@antonydenyer
Copy link
Contributor Author

I don't have control over what other people decide to set as public/private when they try to login to my site using their github login!

@schtauffen
Copy link

schtauffen commented Sep 26, 2018

I don't have control over what other people decide to set as public/private when they try to login to my site using their github login!

@antonydenyer - Adding user:email to @sbruhns suggestion above resolved this issue for me:

config :ueberauth, Ueberauth,
  providers: [
    github: { Ueberauth.Strategy.Github, [default_scope: "user,user:email,public_repo"]}
  ]

Note that the oauth page will specify you are asking for access to all their private email addresses.

user_email

I think this solution is helpful for the elixir bootcamp, but is too heavy handed for production apps.

@antonydenyer
Copy link
Contributor Author

Thanks @schtauffen are you creating a github app or an oauth app?

@schtauffen
Copy link

Thanks @schtauffen are you creating a github app or an oauth app?

I am just using github for oauth (following the elixir bootcamp guide).

ghost pushed a commit to binarytemple/poc_ueberauth that referenced this issue Oct 15, 2018
@feitelogram
Copy link

just thanking @schtauffen and @sbruhns for saving my butt years later

@gameover7
Copy link

I second the above ^ from feitelogram. Thank you guys. How did you figure that out though?

@salilsh
Copy link

salilsh commented May 21, 2021

Got stuck here folks...did everything as @schtauffen and @sbruhns mentioned... any help? 😞

edit: giving up and using public email... (as much as i hate it)

edit 2: while creating the app, ensure that you choose email as read-only under User permissions
image

and default_scope: "user:email" will be enough

config :ueberauth, Ueberauth,
  providers: [
    github: { Ueberauth.Strategy.Github, [default_scope: "user:email"]}
  ]

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

Successfully merging a pull request may close this issue.

9 participants