Python social auth and django, email is blank with Facebook api 2.4

I am using python social auth with my django project to provide facebook login feature. I see that the email is being sent from facebook in a popup. But in my partial conveyor, it becomes empty. The same code worked perfectly with my other Facebook application with the same settings, except for the api version (previously it was 2.3, and now 2.4). There is also no way to change the api version for Facebook to 2.3. My version of python-social-auth 0.2.12 is below the relevant data from my settings file

SOCIAL_AUTH_FACEBOOK_SCOPE = ['email',] FACEBOOK_EXTENDED_PERMISSIONS = ['email',] SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL = True SOCIAL_AUTH_PROTECTED_USER_FIELDS = ['email',] SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/' SOCIAL_AUTH_LOGIN_ERROR_URL = '/' SOCIAL_AUTH_PIPELINE = ( 'social.pipeline.social_auth.social_details', 'social.pipeline.social_auth.social_uid', 'social.pipeline.social_auth.auth_allowed', 'social.pipeline.social_auth.social_user', 'social.pipeline.user.get_username', 'home.pipeline.require_email', 'social.pipeline.social_auth.associate_by_email', # <--- enable this one 'social.pipeline.user.create_user', 'social.pipeline.social_auth.associate_user', 'social.pipeline.social_auth.load_extra_data', 'social.pipeline.user.user_details', 'home.pipeline.send_welcome_mail', ) SOCIAL_AUTH_FACEBOOK_KEY = os.environ['SOCIAL_AUTH_FACEBOOK_KEY'] SOCIAL_AUTH_FACEBOOK_SECRET = os.environ['SOCIAL_AUTH_FACEBOOK_SECRET'] 

This is my partial pipeline custom function.

 @partial def require_email(strategy, backend, uid, details, user=None, *args, **kwargs): print details #some stuff...... 

This function prints an empty email id as shown below.

 {'username': u'Anurag Jain', 'fullname': u'Anurag Jain', 'last_name': u'Jain', 'email': '', 'first_name': u'Anurag'} 

Can someone help me deal with the problem.

+4
source share
1 answer

It turned out that there were some changes made to the api v2.4 on Facebook, as a result of which the email was empty. There is already a problem for this https://github.com/omab/python-social-auth/issues/675

The solution is to add the following parameter to the django configuration file

 SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS = { 'fields': 'id,name,email', # needed starting from protocol v2.4 } 
+6
source

All Articles