3

我正在尝试在我的 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'

网址.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
4

2 回答 2

1

您应该尝试在配置应用程序的同一域上进行测试。

为 test123.youworkserevr.com 之类的域注册 API KEY 并放入您的 hosts 文件:

127.0.0.1       test123.youworkserevr.com

尝试通过 test123.youworkserevr.com 访问您的应用程序(而不是 127.0.0.1 或 localhost)

于 2012-10-22T12:05:28.107 回答
1

这些是我用于 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
于 2012-11-16T05:39:47.877 回答