django-allauth facebook doesn't collect more information other than "name" and "id"

650 views
Skip to first unread message

Saleem Jaffer

unread,
Nov 2, 2015, 7:27:32 AM11/2/15
to Django users
I tried adding facebook login to my application using django-allauth. Unfortunately the only fields that get captured are "name" and "id". All the other information is not captured.

This issue has already been addressed here: https://github.com/pennersr/django-allauth/issues/1061.

Supposedly, using django-allauth version 0.22 and higher should solve this. But I am using 0.23 and still the issue persists. 

Any help will be appreciated!

Vadim Serdiuk

unread,
Nov 2, 2015, 9:29:12 AM11/2/15
to Django users
First you should add SCOPE and FIELDS keys to facebook settings (in file settings.py) to allow allauth your website capture other information

SOCIALACCOUNT_PROVIDERS = {
   
'facebook': {
       
'METHOD': 'oauth2',
       
'SCOPE': ['email', 'public_profile', 'user_friends'],
       
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
       
'FIELDS': [
           
'id',
           
'email',
           
'name',
           
'first_name',
           
'last_name',
           
'link',
           
'gender',
           
'updated_time'],

       
'EXCHANGE_TOKEN': True,
       
'VERIFIED_EMAIL': True,
       
'VERSION': 'v2.4'
   
}
}    

   

Next you should add signup signal handler. It will save extra info into database/ For example:

from allauth.account.signals import user_signed_up, user_logged_in

from django.dispatch import receiver


@receiver(user_signed_up)
def on_user_signed_up(request, user, sociallogin=None, **kwargs):

    if sociallogin:

        if sociallogin.account.provider == 'facebook':
            name = sociallogin.account.extra_data['name']
            user.email = sociallogin.account.extra_data['email']
            user.save()
            if sociallogin.account.extra_data['gender'] == 'male':
                gender = 'M'
            elif sociallogin.account.extra_data['gender'] == 'female':
                gender = 'F'
            user.create_profile(fullname=name, gender=gender)




понедельник, 2 ноября 2015 г., 14:27:32 UTC+2 пользователь Saleem Jaffer написал:

Shahab Emami

unread,
Nov 27, 2017, 10:06:57 PM11/27/17
to Django users
hello 

i have the same problem but for the google.

this is my settings:
SOCIALACCOUNT_PROVIDERS = { 'google':
                             { 'SCOPE': ['email',
                             'https://www.googleapis.com/auth/user.birthday.read',
                             'https://www.googleapis.com/auth/user.phonenumbers.read',
                             'https://www.googleapis.com/auth/contacts',
                             'https://www.googleapis.com/auth/plus.me',
                             ],
                               'AUTH_PARAMS': { 'access_type': 'online' },
                               'FIELDS': [
                                    'birthday',
                                    'phonenumbers'
                                        ],
                             },


                          }

but i don't get phone number  and birthday in extra_data
i'm am sure google is sending them because he asked about sending phone number and birthday 
can you heop me in this?plz

my environment is
ubunto 16
python 3.5
django 1.11
django-allauth 0.34.0

Shahab Emami

unread,
Nov 28, 2017, 4:30:24 PM11/28/17
to Django users
no one is here to answer my question?


On Monday, November 2, 2015 at 3:57:32 PM UTC+3:30, Saleem Jaffer wrote:

Pepal

unread,
Oct 9, 2018, 7:38:01 AM10/9/18
to Django users
Google gives you permission to access user data, but it will not send unless you ping the endpoint to get the birthday. so make sure your app is pinging the correct endpoint.
Reply all
Reply to author
Forward
0 new messages