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'
}
}
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)
SOCIALACCOUNT_PROVIDERS = { 'google': { 'SCOPE': ['email', ], 'AUTH_PARAMS': { 'access_type': 'online' }, 'FIELDS': [ 'birthday', 'phonenumbers' ], },
}