Question

I am trying to enable logging in via facebook,twitter and Google Open Auth 2. I am using the main documentation https://django-social-auth.readthedocs.org/en/latest/index.html. I have also used http://c2journal.com/2013/01/24/social-logins-with-django/

I have put all the necessary configurations in place. Here is my settings.py

....

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',
'django.contrib.auth.backends.ModelBackend',
)

.....

TEMPLATE_CONTEXT_PROCESSORS = (
"social_auth.context_processors.social_auth_by_type_backends",
"django.contrib.auth.context_processors.auth",
 )

......

SOCIAL_AUTH_ENABLED_BACKENDS = ('google','facebook','twitter')

.....

FACEBOOK_APP_ID='**********'
FACEBOOK_API_SECRET='**********************'
FACEBOOK_APP_NAMESPACE = '********_app'
FACEBOOK_EXTENDED_PERMISSIONS = ['email']

GOOGLE_OAUTH2_CLIENT_ID = '***************'
GOOGLE_OAUTH2_CLIENT_SECRET  = '**************************'

TWITTER_CONSUMER_KEY = '***************'
TWITTER_CONSUMER_SECRET = '**********************'

........

INSTALLED_APPS = (
    ............
    'social_auth',
)

I have added social-auth to my urls.py too

(r'^accounts/login/$', 'django.contrib.auth.views.login',
 {'template_name': 'login.html'}),
(r'^accounts/logout/$', 'django.contrib.auth.views.logout_then_login'),

.....

urlpatterns = patterns('',
  ...
    url(r'', include('social_auth.urls')),
  ...
)

On my login.html page, here is how I have called the links

  <div>Login with <a href="{% url socialauth_begin 'facebook' %}">Facebook</a></div>
  </div>Login with <a href="{% url socialauth_begin 'twitter' %}">Twitter</a></div>
  </div>Login with <a href="{% url socialauth_begin 'google-oauth2' %}">Google</a></div>

The problem however, everytime I try logging in via any of these services, It seems the APP Id is missing.

I get this error on Facebook Invalid App ID: None and this one on twitter Only unicode objects are escapable. Got None of type .. Google doesn't work too but It tells me I cannot use raw IP addresses. I am using the server IP address. Please help.

Was it helpful?

Solution

I figured out what was the problem. I had installed python social auth then installed django-social auth. My application was still using the python-social-auth package.

Using the python-social-Auth syntax of naming configuration variables, I added the prefix

SOCIAL_AUTH_

to my config variables so that they now looked like this

SOCIAL_AUTH_FACEBOOK_SECRET='*******************'
SOCIAL_AUTH_FACEBOOK_APP_NAMESPACE = '*******'
SOCIAL_AUTH_FACEBOOK_EXTENDED_PERMISSIONS = ['email']

SOCIAL_AUTH_TWITTER_KEY  = '********'
SOCIAL_AUTH_TWITTER_SECRET = '************'


SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '*************************************'
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET  = '****************'

I can now log in. Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top