Search code examples
djangooauth-2.0google-apigoogle-oauthdjango-socialauth

Google Login error with django-social-auth


I'd created a django project for sign in with google using django-social-auth.

I'd followed the doc and created an app in google developer console with "OAuth 2.0" and added API's of

Gmail API, Google+ API,  Google+ Domains API and Google+ Hangouts API

In Credentials I've set up AUTHORIZED REDIRECT URIS to my production server url "mysite.com".

I'd configured django settings with the "CLIENT ID" and "CLIENT SECRET". This set up works perfectly on my local server, user is created and the email is associated for the user.

But when I moved to the production server, I get the error

"400. That’s an error. OpenID auth request contains an unregistered domain: mysite.com". 

Did any one else faces a similar issue?


Solution

  • I also had the similar issue and I fixed it as follows:

    1. If your google login URL is /login/google/, change it to /login/google-oauth2/
    2. Add the following redirect URIs in your google app settings

    http://<your domain>/<social-auth-prefix-if-any>/complete/google-oauth2/ http://<your domain>/<social-auth-prefix-if-any>/associate/complete/google-oauth2/

    Hope this helps.