Search code examples
pythondjangofacebookdjango-authenticationdjango-allauth

Empty user fields when using django allauth facebook provider


I'm using django and django-allauth. I can successfully authenticate a user using the facebook provider. The problem is that the created user object has all fields empty (first name, last name and email) and the username set to 'user' (which I assume is the default value for the generator). I also have a social account object associated with this user, which has the following data in the Extra data field:

{"name": "my_first_name my_second_name", "id": "my_uuid"}

I've checked overriding the SocialAccountAdapter populate_user function but the data parameter contains a dictionary where first name, last name and email are empty.

Searching up the code, in https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/base.py#L50 the response already comes with only

{"name": "my_first_name my_second_name", "id": "my_uuid"}

so I assume I have a configuration error of some sort with the Facebook provider.

My facebook settings:

SOCIALACCOUNT_PROVIDERS = {
    'facebook': {
        'SCOPE': [
            'email',
            'public_profile',
            'user_friends'
        ],
        'FIELDS': [
            'id',
            'email',
            'name',
            'first_name',
            'last_name',
            'verified',
            'locale',
            'timezone',
            'link',
            'gender',
            'updated_time'
        ],
        'AUTH_PARAMS': {
            #'auth_type': 'reauthenticate'
        },
        'METHOD': 'oauth2',
        #'LOCALE_FUNC': 'path.to.callable',
        'VERIFIED_EMAIL': True,
        'VERSION': 'v2.4'
    }
}

EDIT: I added FIELDS to settings as suggested by WizKid but no progress there


Solution

  • Upgrading to v.023 from v.021 fixed the issue.