I created a Client ID and Client Secret from the google cloud api console and added a record in the Social apps table for django-allauth
I also added WEB ORIGIN
:
mysite.com
(prod)
http://localhost:8000
(dev)
and REDIRECT URI
http:mysite.com/accounts/google/login/callback/
(prod)
localhost:8000/accounts/google/login/callback/
(dev)
in the google api console.
Sign in with Google works great in development and redirects to the localhost callback url on successful sign-in. But I'm getting a redirect_uri_mismatch
error in prod.
These are the error details from the google error page:
Request Details
cookie_policy_enforce=false
scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
response_type=code
access_type=online
redirect_uri=http://127.0.0.1:8000/accounts/google/login/callback/
state=SOME_RANDOM_NUMBER
display=page
client_id=MY_CLIENT_ID
The redirect_uri
is still set to 127.0.0.1
instead of http:mysite.com/accounts/google/login/callback/
So how do I set the proper redirect_uri
?
This is my settings.py
pertaining to django-allauth
INSTALLED_APPS = (
#the usual stuff
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
)
import django.conf.global_settings as DEFAULT_SETTINGS
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + (
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)
AUTHENTICATION_BACKENDS = (
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
)
ACCOUNT_EMAIL_REQUIRED = True
LOGIN_REDIRECT_URL = "/"
Here's urls.py
urlpatterns = patterns('',
url(r'^accounts/', include('allauth.urls')),
)
I haven't made any other django-allauth
settings.
I saw the docs and couldn't find where to make the change.