Django allauth LinkedIn API未返回完整的配置文件数据
我有一个应用程序,我正在试用Django Allauth,特别是LinkedIn api 我正在我的设置中定义范围,如下所示:Django allauth LinkedIn API未返回完整的配置文件数据,django,authentication,oauth,linkedin,django-allauth,Django,Authentication,Oauth,Linkedin,Django Allauth,我有一个应用程序,我正在试用Django Allauth,特别是LinkedIn api 我正在我的设置中定义范围,如下所示: SOCIALACCOUNT_PROVIDERS = \ { 'linkedin': { 'SCOPE': ['r_fullprofile', 'r_emailaddress'] } } 我使用以下方法将此信息输出到模板: {% extends 'base.html' %} {% load auth_extras %} {% lo
SOCIALACCOUNT_PROVIDERS = \
{
'linkedin':
{
'SCOPE': ['r_fullprofile', 'r_emailaddress']
}
}
我使用以下方法将此信息输出到模板:
{% extends 'base.html' %}
{% load auth_extras %}
{% load account %}
{% load socialaccount %}
{% block content %}
{% if user.is_authenticated %}
{% for key, value in user.socialaccount_set.all.0.extra_data.items %}
<ul>
<li>{{ key }}: {{ value }}</li>
</ul>
{% endfor %}
{% endif %}
{% endblock content %}
当我通过LinkedIn授权一个帐户时,我可以看到它正在请求批准基本配置文件、电子邮件地址和完整配置文件。但是user.socialaccount_set.all.0.extra_数据对象仅具有基本配置文件和电子邮件地址数据。完整的配置文件数据发生了什么变化
此外,user.socialaccount\u set.all.0.extra\u数据真的是访问提供者公开的所有数据的最佳方式吗?我最近遇到了这个问题,遇到了这个问题: 简短回答:如果我们在settings.py中定义额外的PROFILE_字段,那么这些字段将被复制到额外的_数据中 为了完整起见,这里是我的settings.py,它包括facebook和linkedin
SOCIALACCOUNT_PROVIDERS = \
{'facebook': {'SCOPE': ['email', 'user_about_me', 'user_birthday',
'user_education_history','user_work_history',
'user_hometown',
'user_location',
'user_religion_politics','user_subscriptions',
'read_stream',
'read_insights',
'read_friendlists',
'user_likes',
'user_interests',
'user_groups'
],
'AUTH_PARAMS': {},
'METHOD': 'oauth2'
},
'linkedin': {'SCOPE': ['r_emailaddress', 'r_fullprofile', 'r_emailaddress', 'r_contactinfo', 'r_network'],
'PROFILE_FIELDS': ['id', 'first-name',
'last-name',
'email-address',
'picture-url',
'public-profile-url', 'skills', 'headline'
]
}
}
我可以使用以下工具打印技能和标题:
@receiver(user_logged_in)
def populate_profile_login2(request, **kwargs):
{
try:
extra_data = kwargs.get('user').socialaccount_set.filter(provider='linkedin')[0].extra_data
for key, value in extra_data.iteritems():
print key, value
except:
print ' NOT LINKEDIN'
}
我最近遇到了这个问题,遇到了这样一个问题: 简短回答:如果我们在settings.py中定义额外的PROFILE_字段,那么这些字段将被复制到额外的_数据中 为了完整起见,这里是我的settings.py,它包括facebook和linkedin
SOCIALACCOUNT_PROVIDERS = \
{'facebook': {'SCOPE': ['email', 'user_about_me', 'user_birthday',
'user_education_history','user_work_history',
'user_hometown',
'user_location',
'user_religion_politics','user_subscriptions',
'read_stream',
'read_insights',
'read_friendlists',
'user_likes',
'user_interests',
'user_groups'
],
'AUTH_PARAMS': {},
'METHOD': 'oauth2'
},
'linkedin': {'SCOPE': ['r_emailaddress', 'r_fullprofile', 'r_emailaddress', 'r_contactinfo', 'r_network'],
'PROFILE_FIELDS': ['id', 'first-name',
'last-name',
'email-address',
'picture-url',
'public-profile-url', 'skills', 'headline'
]
}
}
我可以使用以下工具打印技能和标题:
@receiver(user_logged_in)
def populate_profile_login2(request, **kwargs):
{
try:
extra_data = kwargs.get('user').socialaccount_set.filter(provider='linkedin')[0].extra_data
for key, value in extra_data.iteritems():
print key, value
except:
print ' NOT LINKEDIN'
}
在my linkedin configuration settings.py中,它可用于:
SOCIALACCOUNT_PROVIDERS = \
{
'linkedin':
{'SCOPE': [ 'r_emailaddress',
'r_fullprofile',
'r_emailaddress',
'r_contactinfo',
'r_network'],
'PROFILE_FIELDS':
[
'id',
'first-name',
'last-name',
'email-address',
'picture-url',
'public-profile-url',
'skills',
'headline',
'industry',
'num-connections',
'positions',
'interests',
'languages',
'certifications',
'educations',
'courses',
'three-current-positions',
'three-past-positions',
'recommendations-received',
'honors-awards'
]
}
}
所有字段均在中定义:
您必须确保您在r_fullprofile范围内,才能获得上述所有数据
我的工作对象是:
django allauth==0.14.2
和
Django==1.5.1
我希望这有帮助 在my linkedin configuration settings.py中,它可用于:
SOCIALACCOUNT_PROVIDERS = \
{
'linkedin':
{'SCOPE': [ 'r_emailaddress',
'r_fullprofile',
'r_emailaddress',
'r_contactinfo',
'r_network'],
'PROFILE_FIELDS':
[
'id',
'first-name',
'last-name',
'email-address',
'picture-url',
'public-profile-url',
'skills',
'headline',
'industry',
'num-connections',
'positions',
'interests',
'languages',
'certifications',
'educations',
'courses',
'three-current-positions',
'three-past-positions',
'recommendations-received',
'honors-awards'
]
}
}
所有字段均在中定义:
您必须确保您在r_fullprofile范围内,才能获得上述所有数据
我的工作对象是:
django allauth==0.14.2
和
Django==1.5.1
我希望这有帮助 我在使用新的linkedin_oauth2时遇到了同样的问题。 我花了一点时间才发现我的错误,我使用了错误的提供商名称“linkedin”而不是“linkedin_oauth2” 希望这将有助于其他人在未来 此settings.py配置按预期工作
SOCIALACCOUNT_PROVIDERS = \
'linkedin_oauth2': {'SCOPE': ['r_fullprofile', 'r_emailaddress'],
'PROFILE_FIELDS': ['id', 'first-name',
'last-name',
'email-address',
'picture-url',
'public-profile-url',
'skills', 'headline']}
}
我在使用新的linkedin_oauth2时遇到了同样的问题。 我花了一点时间才发现我的错误,我使用了错误的提供商名称“linkedin”而不是“linkedin_oauth2” 希望这将有助于其他人在未来 此settings.py配置按预期工作
SOCIALACCOUNT_PROVIDERS = \
'linkedin_oauth2': {'SCOPE': ['r_fullprofile', 'r_emailaddress'],
'PROFILE_FIELDS': ['id', 'first-name',
'last-name',
'email-address',
'picture-url',
'public-profile-url',
'skills', 'headline']}
}