python-social-auth / social-app-django

Python Social Auth - Application - Django
BSD 3-Clause "New" or "Revised" License
2.03k stars 380 forks source link

Facebook login - email not in user details #368

Open pbeneteau opened 2 years ago

pbeneteau commented 2 years ago

I'm login on Facebook using their SDK on my frontend.

My scopes:

SOCIAL_AUTH_FACEBOOK_SCOPE = ['public_profile', 'email']

The email is requested when the user accept information permission during login process. But when I exchange the access_token using Django social auth, the email isn't included in the data. I only have the username and id.

When I check on my Facebook account settings, after a login, I can see that my email has been provided to the app.

ghost commented 2 years ago

For Facebook this is what I have:

SOCIAL_AUTH_FACEBOOK_EXTRA_DATA = [ ('name', 'name'), ('email', 'email'), ('picture', 'picture'), ('link', 'profile_url'), ] SOCIAL_AUTH_FACEBOOK_SCOPE = ['email'] SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'id, name, email, age_range',}

Not sure if that will solve your issue but I haven't had issues yet. Not a contributor to PSA but hopefully that helps.

tiago-peres commented 1 year ago

I reckon you were able to solve this issue? I wasn't able to reproduce it but either way you'd have to enforce the email requirement if that is a must.

ddrr1337 commented 1 year ago

For Facebook this is what I have:

SOCIAL_AUTH_FACEBOOK_EXTRA_DATA = [ ('name', 'name'), ('email', 'email'), ('picture', 'picture'), ('link', 'profile_url'), ] SOCIAL_AUTH_FACEBOOK_SCOPE = ['email'] SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {'fields': 'id, name, email, age_range',}

Not sure if that will solve your issue but I haven't had issues yet. Not a contributor to PSA but hopefully that helps.

That solved my problem, thanks for share!

nijel commented 1 year ago

Would you mind updating the documentation with this? See https://python-social-auth.readthedocs.io/en/latest/backends/facebook.html