'i am not get linkedin profile picture url in extra data using django allauth linkedin login

i can't get linkedin profile image in extra data when login using django-allauth. in extra data, profile picture url does't exist. i am using django==4.0.4, django-allauth==0.50.0. this is my setting.py of django application.

#in setting.py
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_extensions',
    'ReviewLink',
    'Users',
    
    # alluth
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',


    #social account providers
    'allauth.socialaccount.providers.linkedin_oauth2',
]

SOCIALACCOUNT_PROVIDERS = {
    'linkedin': {
        'SCOPE': [
            'r_liteprofile',
            'r_emailaddress'
        ],
        'PROFILE_FIELDS': [
            'id', 
            'first-name',
            'last-name',
            'email-address',
            'picture-url',
            'public-profile-url',
        ]
    }
}
SITE_ID = 2

SOCIALACCOUNT_ADAPTER = 'Users.my_adapter.MySocialAccountAdapter'

#my_adapter.py

class MySocialAccountAdapter(DefaultSocialAccountAdapter):

    def pre_social_login(self, request, sociallogin):

        if sociallogin.is_existing:

        print("the social account already exists")

            return   

    def populate_user(self, request, sociallogin, data):


    print(f" Social login account profile data IN POPULATE-USER FUNCTION : {sociallogin.account.extra_data}")
    dictionaryData = sociallogin.account.extra_data
    x = dictionaryData['elements']
    fname = dictionaryData['firstName']
    lname = dictionaryData['lastName']
    country = fname['preferredLocale']

    print(f"Data = {data}")

    print(f'provided provided data  = {data["first_name"]}')
    print(f'provided provided data  = {data["last_name"]}')
    print(f'provided provided data  = {data["email"]}')
        
    #data is a dictionaty  {first_name, Last_name, email}

    try:
        #if the person with this email exists in the database dont do anything

        # person = Person.objects.get(email = data["email"])

        email = PersonEmails.objects.get(email = data["email"])
        return
    except:
        #else add the person

        person = Person()
        
        person.email = data["email"]
        person.firstname = data["first_name"] 
        person.lastname = data["last_name"]
        person.country = country['country']
        person.short_id = shortuuid.uuid()
        person.save()
        
        #add person's email in the list as one person can have more than one email
        emails = PersonEmails()

        emails.email = data["email"]
        emails.person = person
        emails.save()
        
        return

i want to get linkedin profile picture url when i login application. i appriate for your help. i will wait your answer.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source