Django/ python-social-auth: LinkedIn extra data returns null on some fields

泪湿孤枕 提交于 2019-12-24 02:08:38

问题


I am using python-social-auth to retrieve LinkedIn profile data in Django.

<a href="{% url 'social:begin' 'linkedin-oauth2' %}?next={{ request.path }}">Login with LinkedIn</a>

is the link to login with LinkedIn.

SOCIAL_AUTH_LINKEDIN_OAUTH2_EXTRA_DATA = [('id', 'id'), ('firstName', 'first_name'), ('lastName', 'last_name'), ('email-address', 'email_address'), ('positions', 'positions'), ('summary', 'summary'), ('headline', 'headline'), ('picture-url', 'picture_url'),
                       ('site-standard-profile-request', 'site_standard_profile_request'), ('public-profile-url', 'public_profile_url'), ('location', 'location'), ('interests', 'interests'), ('skills', 'skills'), ('languages', 'languages'),]

However, when I check the extra data, it returns only the first name, last name, access token and id correctly. Everything else is null.

What am I missing?


回答1:


The settings to obtain the extra data must be in the following format:

SOCIAL_AUTH_LINKEDIN_FIELD_SELECTORS = [
    'public-profile-url',
    'email-address',
    'interests',
    'skills',
]
SOCIAL_AUTH_LINKEDIN_SCOPE = ['r_basicprofile', 'r_emailaddress']


来源:https://stackoverflow.com/questions/26271545/django-python-social-auth-linkedin-extra-data-returns-null-on-some-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!