2012-10-12 58 views
3

我想在我的Django網站上配置Linkedin auth。我使用django-social-auth我遵循Docs中提到的步驟。我一直堅持這一段時間。無法獲得Linkedin auth與django-social-auth配合使用

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')), 

在我的模板

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

我得到錯誤

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

    Please try again Home 
+0

你還得到「錯誤的請求」錯誤的設置? –

+0

@Erman不,我沒有收到一個「錯誤的請求」 –

+0

我知道這個問題很老,但如果你仍然在使用這個LinkedIn應用程序,你可能想改變你的密鑰,因爲你在這裏暴露它。 –

回答

1

這些都是我用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 = '/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 
+0

嘿拉克什我做了登錄,現在我怎麼可以存儲基本信息在我的數據庫 –

+0

請幫我在這 –

1

你應該嘗試在同一個域測試,應用程序配置。

域註冊API KEY像test123.youworkserevr.com,放在你的hosts文件:

127.0.0.1  test123.youworkserevr.com 

嘗試訪問你的應用程序通過test123.youworkserevr.com(而不是127.0.0.1或本地主機)

+0

我在開發服務器測試它,它不工作有.. –

+0

我是編輯我的答案 – inoks

相關問題