我正在使用 Django-allauth,我启用了社交网络登录、google、facebook 和 twitter,由于某种原因 twitter 无法正常工作,
配置
Settings.py(缩短)
DEBUG = True
SOCIALACCOUNT_QUERY_EMAIL="ACCOUNT_EMAIL_REQUIRED"
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount"
)
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
)
INSTALLED_APPS = (
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.twitter',
)
# Social login
SOCIALACCOUNT_PROVIDERS = \
{ 'facebook':
{ 'SCOPE': ['email', 'publish_stream'],
'AUTH_PARAMS': { 'auth_type': 'reauthenticate' },
'METHOD': 'js_sdk'},
'google':
{ 'SCOPE': ['https://www.googleapis.com/auth/userinfo.profile','https://www.googleapis.com/auth/userinfo.email'],
'AUTH_PARAMS': { 'access_type': 'online' } }
}
# django-allauth settings
EMAIL_CONFIRMATION_DAYS = 7
ACCOUNT_AUTHENTICATION_METHOD = "username"
ACCOUNT_EMAIL_REQUIRED=False
ACCOUNT_EMAIL_VERIFICATION=False
ACCOUNT_USER_DISPLAY=lambda user: user.profile
urls.py(缩短)
urlpatterns = patterns('',
url(r'^accounts/', include('allauth.urls')),
)
推特应用设置
http://my_domain.com/accounts/twitter/login/callback/
消费者密钥和消费者秘密 也配置在 /admin/socialaccount/socialapp/
版本:django-allauth==0.8.1
当我在登录屏幕上单击 Twitter 按钮时,我得到的只是一个标题为“社交网络登录失败”的页面,没有调试屏幕,我可以使用 google 或 facebook 登录。
这是页面上的网址: http://my_domain.com/accounts/twitter/login/callback/?oauth_token=leC3t4BYr9KVAyW22ixxxxxxyVyOHiqaUnIhXwoyRM&oauth_verifier= WdDAwxxxxxxxxMzWAr5tcx3mUfZ63304fsxxxx16qKM