django-social-auth incorrect authentication service
Asked Answered
L

3

5

I was trying to use django-social-auth today, but turned out I got an error everytime I tried to login using it.

I was using the example found in its git master branch, put in my facebook keys, but when I click to login using facebook, the error "Incorrect authentication service" appears.

That also occurs in twitter and orkut logins... does anyone have any idea why that may be happening?

Thanks a lot!

Edit

Yeah, I'm sorry, I forgot to post my code.

settings.py

from os.path import abspath, dirname, basename, join

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ROOT_PATH = abspath(dirname(__file__))
PROJECT_NAME = basename(ROOT_PATH)

ADMINS = (
    # ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'test.db',
    }
}

TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1

USE_I18N = True
USE_L10N = True

MEDIA_ROOT = ''
ADMIN_MEDIA_PREFIX = '/admin-media/'
MEDIA_URL = ''

SECRET_KEY = '****'

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

ROOT_URLCONF = 'urls'

TEMPLATE_DIRS = (
    join(ROOT_PATH, 'templates')
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.admin',
    'social_auth',
    'app',
)

AUTHENTICATION_BACKENDS = (
    'social_auth.backends.twitter.TwitterBackend',
    'social_auth.backends.facebook.FacebookBackend',
    'social_auth.backends.google.GoogleOAuthBackend',
    'social_auth.backends.google.GoogleOAuth2Backend',
    'social_auth.backends.google.GoogleBackend',
    'social_auth.backends.yahoo.YahooBackend',
    'social_auth.backends.contrib.linkedin.LinkedinBackend',
    'social_auth.backends.OpenIDBackend',
    'social_auth.backends.contrib.livejournal.LiveJournalBackend',
    'django.contrib.auth.backends.ModelBackend',
)

try:
    from local_settings import *
except:
    pass

local_settings.py

TWITTER_CONSUMER_KEY              = ''
TWITTER_CONSUMER_SECRET           = ''
FACEBOOK_APP_ID                   = '226521154024720'
FACEBOOK_API_SECRET               = '9955be3b6e211b51921cb4b8eb08e69e'
LINKEDIN_CONSUMER_KEY             = ''
LINKEDIN_CONSUMER_SECRET          = ''
ORKUT_CONSUMER_KEY                = ''
ORKUT_CONSUMER_SECRET             = ''
GOOGLE_OAUTH2_CLIENT_KEY          = ''
GOOGLE_OAUTH2_CLIENT_SECRET       = ''
SOCIAL_AUTH_CREATE_USERS          = True
SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
SOCIAL_AUTH_DEFAULT_USERNAME      = 'socialauth_user'
SOCIAL_AUTH_COMPLETE_URL_NAME     = 'complete'
LOGIN_ERROR_URL                   = '/login/error/'
#SOCIAL_AUTH_USER_MODEL            = 'app.CustomUser'
SOCIAL_AUTH_ERROR_KEY             = 'socialauth_error'

The rest of the codes are exactly the same in example in github.com/omab/django-social-auth if you need any other code, just tell me.

Thanks a lot!

Landes answered 6/6, 2011 at 0:59 Comment(0)
S
1

Well, without seeing your configuration this will simply be a shot in the dark. But the django-social-auth code has this:

def complete_process(request, backend):
    """Authentication complete process"""
    backend = get_backend(backend, request, request.path)
    if not backend:
        return HttpResponseServerError('Incorrect authentication service')
    ...

So, offhand, I would guess that you don't have the right backend configured or, at the very least, Django can't find it. Make sure you have the appropriate backend configured in AUTHENTICATION_BACKENDS and that you've obtained the required OAuth keys from the service you want to use.

Keep in mind, too, that this error occurs in the django-social-auth code in a few places, but always when the specified backend can't be retrieved.

Sporogonium answered 6/6, 2011 at 4:25 Comment(3)
I edited my question, I think the appropriated backends are configured in AUTHENTICATION_BACKENDS, aren't they? I looked into django-social-auth before asking it here, thought it would be what you just said, but, I couldn't see any errors in my config... Thanks!Landes
Well, nevermind, it was a stupid mistake... The local_settings was named local_settings_template, but I didn't notice it at all. Sorry guys. I think I'm dislexic...Landes
I don't think you're dyslexic -- I think simple things like this happen all the time when you're staring at code for awhile. Sometimes it helps just to have another pair of eyes! Happy coding.Sporogonium
S
11

In my case the problem was that I had FACEBOOK_APP_SECRET instead of FACEBOOK_API_SECRET. It was due to the fact that I migrated from django-facebook to django-social-auth.

Surefooted answered 21/3, 2012 at 10:58 Comment(2)
Oh how I LOVE Stack Overflow for comments like this!Doroteya
Did it help you? :) Did you do the same migration?Surefooted
W
4

It may be you don't have the FACEBOOK_APP_ID or FACEBOOK_API_SECRET set.

Whistling answered 26/1, 2012 at 17:50 Comment(0)
S
1

Well, without seeing your configuration this will simply be a shot in the dark. But the django-social-auth code has this:

def complete_process(request, backend):
    """Authentication complete process"""
    backend = get_backend(backend, request, request.path)
    if not backend:
        return HttpResponseServerError('Incorrect authentication service')
    ...

So, offhand, I would guess that you don't have the right backend configured or, at the very least, Django can't find it. Make sure you have the appropriate backend configured in AUTHENTICATION_BACKENDS and that you've obtained the required OAuth keys from the service you want to use.

Keep in mind, too, that this error occurs in the django-social-auth code in a few places, but always when the specified backend can't be retrieved.

Sporogonium answered 6/6, 2011 at 4:25 Comment(3)
I edited my question, I think the appropriated backends are configured in AUTHENTICATION_BACKENDS, aren't they? I looked into django-social-auth before asking it here, thought it would be what you just said, but, I couldn't see any errors in my config... Thanks!Landes
Well, nevermind, it was a stupid mistake... The local_settings was named local_settings_template, but I didn't notice it at all. Sorry guys. I think I'm dislexic...Landes
I don't think you're dyslexic -- I think simple things like this happen all the time when you're staring at code for awhile. Sometimes it helps just to have another pair of eyes! Happy coding.Sporogonium

© 2022 - 2024 — McMap. All rights reserved.