gpt4 book ai didi

django - 无法让 Linkedin 身份验证与 django-social-auth 一起使用

转载 作者:行者123 更新时间:2023-12-02 05:02:09 25 4
gpt4 key购买 nike

我正在尝试在我的 Django 网站上配置 Linkedin 身份验证。我用django-social-auth我按照 Docs 中提到的步骤操作。我已经被这个问题困扰了很长一段时间了。

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'

url.py

url(r'', include('social_auth.urls')),

在我的模板中

<a href="{% url socialauth_begin 'linkedin' %}">linkedin</a>

我收到错误

Error!
Sorry but some error made you impossible to login.

Please try again Home

最佳答案

这些是我用于 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

关于django - 无法让 Linkedin 身份验证与 django-social-auth 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12853038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com