3

我正在尝试通过 BitBucket、Github、LinkedIn 实现社交媒体身份验证,并且在 /login/error/ 处收到错误 WrongBackend,LinkedIn 和 Bitbucket 和 QueryDict 的身份验证服务“错误”:{u'error': [u'用于 Github 的 redirect_uri_mismatch']}。

我使用 MongoEngine 作为数据库存储

这是 Bitbucket 的回溯(与 LinkedIn 类似)

Environment:


Request Method: GET
Request URL: http://localhost:8000/login/error/

Django Version: 1.4.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'blogapp',
 'social_auth')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/social_auth/decorators.py" in wrapper
  29.                 raise WrongBackend(backend)

Exception Type: WrongBackend at /login/error/
Exception Value: Incorrect authentication service "error"

我在异常“/usr/local/lib/python2.7/dist-packages/social_auth/decorators.py”的位置添加了一个跟踪,并得到了以下跟踪。任何人都可以让我知道我要去哪里错了吗?这非常令人沮丧。

我的应用程序具有以下设置

在所有服务中,我已将我的应用程序 url 注册为 localhost:8000 并将回调 url 注册为 localhost:8000/callback/

[编辑]

我创建了一个答案中提到的 sqlite3 表,它创建了一些表。但问题依然存在。

4

2 回答 2

0

编辑:我之前关于使用 sqlite3 db 的回应是基于错误的假设。看看这里的代码是怎么回事

  1. 您正在注释掉 LOGIN_ERROR_URL。在这种情况下,工作流程会将我带到 Linked 并引发您提到的错误。
  2. 当您取消注释此行并尝试时,您可以看到它会将您重定向到登录错误回调。

所以我的猜测是你需要取消注释这一行,在你注册了 Linked In 应用程序的域上部署这个代码并在那里测试它。(我想问题的一部分是你像我一样在 Localhost 上测试它)

于 2013-03-25T16:32:55.363 回答
0

我认为您的问题是回调 URL。您告诉那些服务它是 localhost:8000/callback,但 django-social-auth 以以下形式提供它的回调:/complete/(例如,/complete/github)。它不是所有这些后端的一个 URL。

于 2013-03-26T03:12:09.113 回答