ueberauth / ueberauth_github

GitHub OAuth2 Strategy for Überauth
MIT License
103 stars 53 forks source link

email is nil when authenticating using github app credentials #41

Closed antonydenyer closed 5 years ago

antonydenyer commented 6 years ago

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?

moroz commented 6 years ago

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 commented 6 years ago

Added an option to fix the issue in #42

sbruhns commented 6 years ago

@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 commented 6 years ago

@sbruhns That did not do the trick for me.

jakecurreri commented 6 years ago

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

antonydenyer commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

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

schtauffen commented 5 years ago

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

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

feitelogram commented 4 years ago

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

gameover7 commented 4 years ago

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

salilsh commented 3 years ago

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"]}
  ]