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 
написал:
>
> 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!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ae3add24-5b57-4cd9-87b7-a2720d3cc3d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to