无法获取LinkedIn AUTH一起工作Django的社会身份验证 [英] Unable to get Linkedin auth to work with django-social-auth
本文介绍了无法获取LinkedIn AUTH一起工作Django的社会身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的Django的网站配置LinkedIn权威性。我使用 Django的社会权威性我按照步骤中提到在文档。我一直停留在这个相当长的一段时间。
我的settings.pyINSTALLED_APPS =(
'django.contrib.auth',
django.contrib.contenttypes',
django.contrib.sessions',
django.contrib.sites',
django.contrib.admin',
social_auth',mytests
)AUTHENTICATION_BACKENDS =('social_auth.backends.contrib.linkedin.LinkedinBackend',
django.contrib.auth.backends.ModelBackend',)TEMPLATE_CONTEXT_PROCESSORS =(
django.contrib.auth.context_processors.auth',
django.core.context_processors.debug',
django.core.context_processors.i18n',
django.core.context_processors.media',
django.contrib.messages.context_processors.messages',
social_auth.context_processors.social_auth_by_name_backends',
social_auth.context_processors.social_auth_backends',
social_auth.context_processors.social_auth_by_type_backends',
social_auth.context_processors.social_auth_login_redirect',
)SOCIAL_AUTH_ENABLED_BACKENDS =('LinkedIn',)LINKEDIN_CONSUMER_KEY ='py5pspq52ypesv'#API关键
LINKEDIN_CONSUMER_SECRET ='OyzsrC5GqIo85z9GsWc'#Secret关键LOGIN_REDIRECT_URL =复选框
LOGIN_ERROR_URL ='/登录错误/SOCIAL_AUTH_COMPLETE_URL_NAME ='socialauth_complete
SOCIAL_AUTH_ASSOCIATE_URL_NAME ='socialauth_associate_complete
urls.py
URL(R'',包括('social_auth.urls'))
在我的模板
< A HREF ={%URL socialauth_begin'LinkedIn'%}> LinkedIn< / A>
我得到错误
错误!
很抱歉,但有些错误让你无法登录。 请重试首页
解决方案
这是我用LinkedIn验证的设置
SOCIAL_AUTH_PIPELINE =(
social_auth.backends.pipeline.social.social_auth_user',
social_auth.backends.pipeline.user.get_username',
social_auth.backends.pipeline.user.create_user',
social_auth.backends.pipeline.social.associate_user',
social_auth.backends.pipeline.social.load_extra_data',
social_auth.backends.pipeline.user.update_user_details',
social_auth.backends.pipeline.associate.associate_by_email
)LOGIN_REDIRECT_URL ='/家居/'
LOGIN_ERROR_URL ='/ login_error /TEMPLATE_CONTEXT_PROCESSORS + =(
social_auth.context_processors.social_auth_by_name_backends',
social_auth.context_processors.social_auth_backends',
social_auth.context_processors.social_auth_by_type_backends',
social_auth.context_processors.social_auth_login_redirect',
)AUTHENTICATION_BACKENDS =(
social_auth.backends.contrib.linkedin.LinkedinBackend',
django.contrib.auth.backends.ModelBackend',
)的SOCIAL_AUTH_ENABLED_BACKENDS,SOCIAL_AUTH_COMPLETE_URL_NAME SOCIAL_AUTH_ASSOCIATE_URL_NAME不需要
I am trying to configure Linkedin auth on my Django website. I use django-social-auth I follow the steps mentioned in the Docs. I have been stuck on this for quite some time.
My settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'social_auth',
'mytests'
)
AUTHENTICATION_BACKENDS = ( 'social_auth.backends.contrib.linkedin.LinkedinBackend',
'django.contrib.auth.backends.ModelBackend',)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.contrib.messages.context_processors.messages',
'social_auth.context_processors.social_auth_by_name_backends',
'social_auth.context_processors.social_auth_backends',
'social_auth.context_processors.social_auth_by_type_backends',
'social_auth.context_processors.social_auth_login_redirect',
)
SOCIAL_AUTH_ENABLED_BACKENDS = ('linkedin',)
LINKEDIN_CONSUMER_KEY = 'py5pspq52ypesv' #API Key
LINKEDIN_CONSUMER_SECRET = 'OyzsrC5GqIo85z9GsWc' #Secret Key
LOGIN_REDIRECT_URL = 'checkbox'
LOGIN_ERROR_URL = '/login-error/'
SOCIAL_AUTH_COMPLETE_URL_NAME = 'socialauth_complete'
SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'
urls.py
url(r'', include('social_auth.urls')),
And in my Template
<a href="{% url socialauth_begin 'linkedin' %}">linkedin</a>
I get Error
Error!
Sorry but some error made you impossible to login.
Please try again Home
解决方案
These are the settings i used for Linkedin Auth
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details',
'social_auth.backends.pipeline.associate.associate_by_email'
)
LOGIN_REDIRECT_URL = '/home/'
LOGIN_ERROR_URL = '/login_error/'
TEMPLATE_CONTEXT_PROCESSORS += (
'social_auth.context_processors.social_auth_by_name_backends',
'social_auth.context_processors.social_auth_backends',
'social_auth.context_processors.social_auth_by_type_backends',
'social_auth.context_processors.social_auth_login_redirect',
)
AUTHENTICATION_BACKENDS = (
'social_auth.backends.contrib.linkedin.LinkedinBackend',
'django.contrib.auth.backends.ModelBackend',
)
The SOCIAL_AUTH_ENABLED_BACKENDS, SOCIAL_AUTH_COMPLETE_URL_NAME SOCIAL_AUTH_ASSOCIATE_URL_NAME are not required
这篇关于无法获取LinkedIn AUTH一起工作Django的社会身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文