Reputation: 1033
All other configurations result in login failure(SERVER 500 ERROR). After a dozen permutation of different combinations, the only configuration with login success but still misses fields in extra_data is as follows. The missing fields can be 'skills', 'summary' from 'r_basicprofile' scope.
Am I missing some import information? Please let me know if you spot it. I have been reading the source code of django-allauth to understand this issue.
Actually, there are two issues here:
PROFILE_FIELDS
not populated into extra_data?My Linkedin social login app was created recently. So, it is using the OAuth2.0 instead of OAuth1.0, right? I followed the instruction on the doc https://django-allauth.readthedocs.org/en/latest/providers.html?highlight=provider_login_url#linkedin which says 'Leave the OAuth redirect URL empty.'
The configuration that still misses fields but enable login success: In template login.html, use 'linkedin'
<a href="{% provider_login_url 'linkedin' %}" class="btn btn-block btn-social btn-linkedin">
In settings.py, use 'linkedin' in INSTALLED_APPS, and 'linkedin_oauth2' in SOCIALACCOUNT_PROVIDERS.
I did not put { 'r_contactinfo', 'r_network'} in the 'SCOPE' as it requires 'Apply with Linkedin' program application and approval.
INSTALLED_APPS=(
...
'allauth',
'allauth.account',
'allauth.socialaccount',
#providers
'allauth.socialaccount.providers.linkedin',
....
)
SOCIALACCOUNT_PROVIDERS = \
{'linkedin_oauth2':
{'SCOPE': ['r_emailaddress', 'r_basicprofile'],
'PROFILE_FIELDS': ['id',
'first-name',
'last-name',
'email-address',
'picture-url',
'picture-urls::(original)', # picture-urls::(original) is higher resolution
'public-profile-url',
'skills',
'headline'
'location',
'industry',
]}
}
All failed configurations are as follows. Use ONLY linkedin_oauth2 in INSTALLED_APPS. Still use linkedin_auth2 in SOCIALACCOUNT_PROVIDERS
INSTALLED_APPS=(
...
'allauth',
'allauth.account',
'allauth.socialaccount',
#providers
'allauth.socialaccount.providers.linkedin_oauth2',
....
)
login.html can be
OR
In my debug logging message, here is the typical error.
Using linkedin_oauth2
in provider_login_url
causes
ERROR 13/Dec/2015 19:22:48 base 1217 139681546774272 [django.request:256] Internal Server Error: /accounts/linkedin_oauth2/login/
Traceback (most recent call last):
File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/python/run/venv/lib/python3.4/site-packages/allauth/socialaccount/providers/oauth2/views.py", line 55, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/python/run/venv/lib/python3.4/site-packages/allauth/socialaccount/providers/oauth2/views.py", line 78, in dispatch
app = provider.get_app(self.request)
File "/opt/python/run/venv/lib/python3.4/site-packages/allauth/socialaccount/providers/base.py", line 38, in get_app
return SocialApp.objects.get_current(self.id, request)
File "/opt/python/run/venv/lib/python3.4/site-packages/allauth/socialaccount/models.py", line 31, in get_current
provider=provider)
File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/query.py", line 334, in get
self.model._meta.object_name
allauth.socialaccount.models.DoesNotExist: SocialApp matching query does not exist.
OR
If only linkedin_oauth2 is included in INSTALLED_APPS, using linkedin
in provider_login_url
causes this
File "/opt/python/run/venv/lib/python3.4/site-packages/django/template/defaulttags.py", line 329, in render
return nodelist.render(context)
File "/opt/python/run/venv/lib/python3.4/site-packages/django/template/base.py", line 903, in render
bit = self.render_node(node, context)
File "/opt/python/run/venv/lib/python3.4/site-packages/django/template/base.py", line 917, in render_node
return node.render(context)
File "/opt/python/run/venv/lib/python3.4/site-packages/allauth/socialaccount/templatetags/socialaccount.py", line 17, in render
provider = providers.registry.by_id(provider_id)
File "/opt/python/run/venv/lib/python3.4/site-packages/allauth/socialaccount/providers/__init__.py", line 20, in by_id
return self.provider_map[id]
KeyError: 'linkedin'
Upvotes: 0
Views: 1195
Reputation: 1033
This will be helpful to others who may run into this issue. I fixed the issue by change the LinkedOAuth2's token_url which is updated in Linkedin OAuth2's api manual.
Upvotes: -1
Reputation: 65
you have to use "linkedin_oauth2" instead of "linkedin".
href="{% provider_login_url 'linkedin_oauth2' %}" class="btn btn-block btn-social btn-linkedin"
Upvotes: 1