Thank you! Your feedback has been delivered
Thank you! Your feedback has been sent

Login via google and facebook using django-social-auth

I am trying to integrate django-social-auth on my django app which is running on google app engine. I am trying to implement google-oauth2 and facebook oauth login using django-social-auth.

SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = '377490210257-**' SOCIAL_AUTH_GOOGLE_OAUTH2_CLIENT_SECRET = '*****' SOCIAL_AUTH_FACEBOOK_APP_ID = '**' SOCIAL_AUTH_FACEBOOK_SECRET = 'xxxx'

AUTHENTICATION_BACKENDS = ( 'social_auth.backends.facebook.FacebookBackend', 'social_auth.backends.google.GoogleOAuth2Backend', 'django.contrib.auth.backends.ModelBackend', )

When I try to login via google oauth, I get the following error:

TooManyRedirects at /complete/google-oauth2/ Exceeded 30 redirects.

When I try to login via facebook auth, I get the following error:

HTTPError at /complete/facebook/ 400 Client Error: Bad Request

I am not sure whether are there any other configuration that needs to be done to make it run. Since google app engine doesn't have django-social-auth as the library, I had to manually put all the libraries in the source folde

User Gravatar

user1219

Posted Feb 2 2014 16:05 UTC

$30


  • Expired
  • python
    facebook
  • 3081 Views

4 Replies


I believe you misspelled these values by adding "SOCIAL_AUTH_" as a prefix. The documentation for Google (http://django-social-auth.readthedocs.org/en/latest/backends/google.html):

To enable OAuth2 support:

fill Client ID and Client Secret settings, these values can be obtained easily as described on OAuth2 Registering doc:

GOOGLE_OAUTH2_CLIENT_ID = ''
GOOGLE_OAUTH2_CLIENT_SECRET = ''

previous name GOOGLE_OAUTH2_CLIENT_KEY is supported for backward compatibility.

and for Facebook (http://django-social-auth.readthedocs.org/en/latest/backends/facebook.html):

Back to your django settings.py file, fill in the App ID and App Secret values from the blue box in step #3

FACEBOOK_APP_ID='App ID here'
FACEBOOK_API_SECRET='App Secret here'

Make sure that you have the Facebook backend added to AUTHENTICATION_BACKENDS

AUTHENTICATION_BACKENDS = (
    'social_auth.backends.facebook.FacebookBackend',
)

Your "AUTHENTICATION_BACKENDS" values seems to be alright

User Gravatar

zed1979

Posted Feb 3 2014 9:36 UTC

I had also tried without the SOCIAL_AUTH also, it didn't worked. It was throwing invalid client id error.

User Gravatar

user1219

Posted Feb 3 2014 10:14 UTC

well... according to their article: http://django-social-auth.readthedocs.org/en/latest/index.html

the library is deprecated.

anyway, I can see that the variables are correct. have you registered your client_id as a "Web application"? could it be that you are using keys for "Service account" or "Installed application"?

it can also be that the redirection url (LOGIN_REDIRECT_URL parameter) is incorrect (thus, leading to the authentication page again)

User Gravatar

zed1979

Posted Feb 4 2014 11:37 UTC

I even moved to python-social-auth and tried with the example provided in the library. While running as django application, the application seems to work. But when I run it on google app engine, it throws me the error. I had sent a mail to Matias, asking for help. Here is the reply

Hi,

I've checked the POST and frankly I can't say much since my appengine experience is None.

Regarding the TooManyRedirects exception, this is the first time I see that happening, and according to python-requests docs this is raised when (as the exception says) there are too many redirects going on when opening an URL, I guess this might be a restriction on appengine since the URL being opened works just fine locally.

About Facebook, I'm confused and not sure what could be happening, I've tried your site and Facebook login and saw the error in your server, but then I've tried the same server request (borrowed the data from the traceback) and it worked as expected.

So, I would start by checking any appengine policy or config that might be getting in the middle of any request to third-party APIs.

Best, Matías

User Gravatar

user1219

Posted Feb 4 2014 12:17 UTC

Add a reply

By posting a reply on CodersClan you agree to our Terms & Conditions