3

I've installed django-social-auth.

It seems to work except I only have random authentication links show up in the list of authentication options. In the oAuth list, I can only see:

  • Google-Oauth
  • Linkedin
  • Github
  • Orkut

I'm trying to get Facebook authentication to work.

Here are my settings related to django-social-auth:

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',
)



INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',
    'south',
    'appMain',
    'social_auth',
)



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.contrib.flickr.FlickrBackend',
    'social_auth.backends.OpenIDBackend',
    'social_auth.backends.contrib.livejournal.LiveJournalBackend',
    'django.contrib.auth.backends.ModelBackend',
)


TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.contrib.messages.context_processors.messages',
    'social_auth.context_processors.social_auth_by_type_backends',
)

# SOCIAL_AUTH_ENABLED_BACKENDS = ('google', 'google-oauth', 'twitter', 'facebook',)

LOGIN_URL = '/login-form/'
LOGIN_REDIRECT_URL = '/logged-in/'
LOGIN_ERROR_URL = '/login-error/'

SOCIAL_AUTH_COMPLETE_URL_NAME  = 'socialauth_complete'
SOCIAL_AUTH_ASSOCIATE_URL_NAME = 'socialauth_associate_complete'

TWITTER_CONSUMER_KEY              = ''
TWITTER_CONSUMER_SECRET           = ''
FACEBOOK_APP_ID                   = '126197457491070'
FACEBOOK_APP_SECRET               = '2ed91326e1a7c88db7358727856877dc'
LINKEDIN_CONSUMER_KEY             = ''
LINKEDIN_CONSUMER_SECRET          = ''
ORKUT_CONSUMER_KEY                = ''
ORKUT_CONSUMER_SECRET             = ''
GOOGLE_OAUTH2_CLIENT_ID           = ''
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     = 'socialauth_complete'
LOGIN_ERROR_URL                   = '/login/error/'
#SOCIAL_AUTH_USER_MODEL            = 'upfoMain.CustomUser'
SOCIAL_AUTH_ERROR_KEY             = 'socialauth_error'
GITHUB_APP_ID                     = ''
GITHUB_API_SECRET                 = ''
FOURSQUARE_CONSUMER_KEY           = ''
FOURSQUARE_CONSUMER_SECRET        = ''

I've checked all of the settings several times. I can't really see anything missing so I wonder where the problem might be?

In the front-end template, the code is (directly from django-social-auth example):

<div>
  <h3>Login using <a href="http://oauth.net/" title="OAuth">OAuth</a> from:</h3>
  <ul>
  {% for name in social_auth.backends.oauth %}
    <li><a rel="nofollow" href="{% url socialauth_begin name %}">{{ name|title }}</a></li>
  {% endfor %}
  </ul>
</div>
TaiwanGrapefruitTea
  • 1,045
  • 2
  • 14
  • 25
Riku
  • 2,223
  • 2
  • 17
  • 20

2 Answers2

3

I found the problem, I'm not really sure why this has happened:

In Facebook settings, The app_secret is called "App secret". So quickly looking through, I had defined "APP_SECRET". I think I actually had that copied from another app. However, in the code, App secret is defined as "API_SECRET". So just by changing that, it works. Maybe this will be useful to someone.

Riku
  • 2,223
  • 2
  • 17
  • 20
0

Facebook uses OAuth2 so it will be under social_auth.backends.oauth2 key, try this snippet instead:

{% for name in social_auth.backends.oauth2 %}
    <li><a rel="nofollow" href="{% url socialauth_begin name %}">{{ name|title }}</a></li>
{% endfor %}

I hope those aren't your real Facebook APP_ID and APP_SECRET

omab
  • 3,721
  • 19
  • 23
  • I have that code as well. Unfortunately still not showing. On the example page http://social.matiasaguirre.net/ Facebook showing in oauth, not oauth2 (although that's not the same version apparently.) – Riku Dec 09 '11 at 18:19
  • Yeah, not same version... yet ;) – omab Dec 14 '11 at 04:21