使用Djangoallauth我无法使用Twitch登录

2024-10-01 05:04:52 发布

您现在位置:Python中文网/ 问答频道 /正文

更新-我让allauth按照我尝试Twitch的相同步骤与google合作。在

首先,我对编程什么都不熟悉。这是我在教程之外的第一个项目。在

我想用django allauth用Twitch登录。我的项目没有自动启动,但我的社交项目。我可以用我的网站上的帐户登录。在

添加'allauth.socialaccount.providers.twitch',对于已安装的应用程序,twitch链接会出现在登录页面上。我在http://www.twitch.tv/kraken/oauth2/clients/new注册了我的应用程序,并将所有内容复制到管理社交应用程序页面。在

点击Twitch登录链接后,我得到以下错误:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/twitch/login/callback/?code=8lhhsf461v7ksw0no3ajlwfslbdtia&scope=&state=xxKe31qCbow2

Django Version: 1.7.1
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'crispy_forms',
 'avatar',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.twitch',
 'users',
 'debug_toolbar')
Installed Middleware:
('djangosecure.middleware.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware')


Traceback:
File "/home/brian/Envs/trycookie/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/brian/Envs/trycookie/local/lib/python2.7/site-packages/allauth/socialaccount/providers/oauth2/views.py" in view
  53.             return self.dispatch(request, *args, **kwargs)
File "/home/brian/Envs/trycookie/local/lib/python2.7/site-packages/allauth/socialaccount/providers/oauth2/views.py" in dispatch
  102.                                                 response=access_token)
File "/home/brian/Envs/trycookie/local/lib/python2.7/site-packages/allauth/socialaccount/providers/twitch/views.py" in complete_login
  21.                                                              extra_data)
File "/home/brian/Envs/trycookie/local/lib/python2.7/site-packages/allauth/socialaccount/providers/base.py" in sociallogin_from_response
  45.         uid = self.extract_uid(response)
File "/home/brian/Envs/trycookie/local/lib/python2.7/site-packages/allauth/socialaccount/providers/twitch/provider.py" in extract_uid
  25.         return str(data['_id'])

Exception Type: KeyError at /accounts/twitch/login/callback/
Exception Value: '_id'

我将尝试在我的项目代码中提供我认为相关的所有内容。如果我忘了什么,请告诉我。在

在设置.py(更名普通.py在库奇卡特django)

^{pr2}$

在网址.py在

url(r'^users/', include("users.urls", namespace="users")),
url(r'^accounts/', include('allauth.urls')),

Twitch注册页面和我的管理页面中的所有信息都应该匹配。我把它都抄了/贴了下来,检查了好几次。删除所有信息并重新输入。在


Tags: djangopyhomeliblocalcontribmiddlewarefile