1
votes

I am using python social auth to connect with facebook but I am not getting email of the user In my settings I have added :

SOCIAL_AUTH_FACEBOOK_SCOPE = ['email',]
SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = {
 'fields': 'id, name, email, age_range'
}

and I have written custom pipeline to get users email:

def create_user_profile(strategy, details, response, user=None, *args, **kwargs):
    print(kwargs['response'].get('name'))

Here I can not get user email

How can i get user's email. Need advice

1
Why do you fetch the 'name' field instead the 'email' one? - FSp

1 Answers

1
votes

As far as I know, email is not included in the basic scope. That's why you need to explicitly show that you want email as well.

Do this in your settings file:

SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']

and try to register a user through Facebook. He will be asked whether he agrees to grant those permissions, including email. If he agrees, you will get his email in response['email']