Can't configure redirect uris for django allauth + google oauth

30 Views Asked by At

I'm setting my django app on google cloud's standard webapp engine, and i can't find anywhere a way to configure the correct redirect_uri for my OAuth2 client. It works well on my machine when i start google cloud's sql proxy, but i can't make it work on the cloud.

I'm able to avoid the uri_mismatch error by changing the 'uri_redirect' value on my settings file:

SOCIALACCOUNT_PROVIDERS = { 'google': { 'SCOPE': [ 'profile', 'email', ], 'AUTH_PARAMS': { 'access_type': 'online', 'redirect_uri':'https://localhost' } } }

But, of course it doesn't work since the app isn't running on my machine. I already tried to change the site in django model admin to different values, didn't seem to work. And i just can't find where to change it in the google cloud console either. It was supposed to be in Credentials > OAuth 2.0 client IDs, but... it's not? I can download the json file with my key, and it has a redirect_uri, but it's http://localhost!(That's where i came up with the idea of changing it in the settings to localhost for avoiding uri_mismatch).

screenshot from google cloud console

All the stuff from allauth looks like this in my settings.py file:

`SITE_ID = 1

LOGIN_REDIRECT_URL = '/'

SOCIALACCOUNT_QUERY_EMAIL = True
ACCOUNT_LOGOUT_ON_GET= True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_EMAIL_REQUIRED = True
AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
)

SOCIALACCOUNT_PROVIDERS = {
    'google': {
        'SCOPE': [
            'profile',
            'email',
        ],
        'AUTH_PARAMS': {
            'access_type': 'online',
            'redirect_uri':'https://mydomain.com.br/accounts/google/login/callback'
        }
    }
}`

`Thanks in advance.

0

There are 0 best solutions below