3

I'm trying to implement social media authentication via BitBucket, Github, LinkedIn and am getting the error WrongBackend at /login/error/ Incorrect authentication service "error" for both LinkedIn and Bitbucket and QueryDict: {u'error': [u'redirect_uri_mismatch']} for Github.

I'm using MongoEngine as the database store

Here's the traceback for Bitbucket (similar with 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"

I added a trace to the location of the exaception "/usr/local/lib/python2.7/dist-packages/social_auth/decorators.py" and got the following trace. Can anyone please let me know where I'm going wrong? It's been very frustrating.

My application has the following settings

In all the services, I have registered my application url as localhost:8000 and callback url as localhost:8000/callback/

[EDIT]

I created the sqlite3 table as mentioned in one of the answers and it created a few tables. But the problems persist.

6
  • You get WrongBackend because DSA catches that /login/error/ URL as it was a /login/<backend>/ path, so it tries to load a backend which name is error, which of course doesn't exists. First try changing that URL or put the handler for that path before DSA URLs are included. After you do that, we can check what's going on with those APPs that are dropping some error and halts the auth process.
    – omab
    Mar 26, 2013 at 15:47
  • Usually that kind problem is caused by the pipeline, you have a custom entry in your pipeline, it's reached at any point or the process halts before? I would try to identify the entry that causes the problem.
    – omab
    Mar 27, 2013 at 0:02
  • @omab I did what you mentioned, and found that the error occurs in 'social_auth.backends.pipeline.user.create_user'. On tracing it out, I figured I had missed 'get_username' that it depended on. Also, on going through django-social-auth.readthedocs.org/en/latest/pipeline.html again, I found that the ordering of the pipelines was wrong. So, after doing all this, it is crossing the pipelines, but still, not finishing successfully. Mar 27, 2013 at 1:18
  • I'm now getting a TypeError that says "save() got an unexpected keyword argument 'update_fields'". The traceback for the error is at paste.kde.org/710240 . Any ideas? Mar 27, 2013 at 1:36
  • Mongoengine doesn't have support for Django 1.5 yet, they have this issue but still no updated. I think you could subclass their User instance and override the save method.
    – omab
    Mar 27, 2013 at 15:56

2 Answers 2

0

I think your problem is the callback URL. You're telling those services it's localhost:8000/callback, but django-social-auth provides it's callbacks in the form: /complete/ (e.g., /complete/github). It's not one URL for all of those backends.

1
  • If so, what value should the variable LOGIN_REDIRECT_URL hold? Anyway, I commented that variable out, and updated my applications in the service providers. No change at all (except with Github. Instead of redirect uri mismatch, it too now raises WrongBackend) Mar 26, 2013 at 4:23
0

EDIT: My Previous response about using sqlite3 db was based on wrong assumptions. Looking at code here is whats happening

  1. You're commenting out LOGIN_ERROR_URL. When this is the case the workflow takes me to Linked and it raises error you have mentioned.
  2. When you un-comment this line and try you can see it redirects you to login-error callback.

So my guess is you need to uncomment this line, deploy this code on domain where you have registered Linked In application and test it over there. (I guess part of the problem would be you're testing it on Localhost like I was)

4
  • I followed your advice and added the entries and ran syncdb, but the problem persists Mar 25, 2013 at 22:41
  • Is it possible for you to host you're code somewhere I can clone and take a look at whats going on? Mar 26, 2013 at 1:04
  • You don't have to store anything you don't need in SQL tables. You're already using MongoEngine, it provides a Django session backend in addition to the auth backend you're already using. I don't think this is your problem at all.
    – StevenC
    Mar 26, 2013 at 3:04
  • I have registered the domain as localhost:8000 itself (everywhere), so that still doesn't explain why LOGIN_ERROR is being thrown Mar 26, 2013 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.