Skip to content

Google Social Authentication

Read Context

For reusability, ensure to read the discussion on context so that the environment variables that are secured can be repurposed for testing in other websites later on.

Field Value
Homepage url http://127.0.0.1:8000/
Callback url http://127.0.0.1:8000/accounts/google/login/callback

0.0.0.0:8080 as Google redirect url

Cannot register a container context for Google because the redirect uri of 0.0.0.0:8080 does not meet the validation criteria for a valid domain.

Replace start-django.fly.dev with the new site.

Field Value
Homepage url e.g. https://start-django.fly.dev
Callback url e.g. http://start-django.fly.dev/accounts/google/login/callback/
User support email address Should be part of Google organization
Developer contact email address -
Test user email addresses (< 100) -

AllAuth

We need to secure the following values:

Key Value
GOOGLE_ID Client id
GOOGLE_KEY Client secret

This is per the configuration we set via django-allauth:

/config/settings/_auth.py
SOCIALACCOUNT_PROVIDERS = {
    "github": {
        "APP": {
            "client_id": env("GOOGLE_ID", None),
            "secret": env("GOOGLE_KEY", None),
            "key": "",
        }
    },
    ...
}

Visit console.

Create an app:

Screenshot of Google oAuth consent screen form

According to the External User Type for testing:

Your app will only be available to users you add to the list of test users. Once your app is ready to publish, you may need to verify your app.

Note optional badges of trust

  1. App logo
  2. Link to privacy policy as a badge of trust
  3. Link to terms of service

Credentials screen

After completing requisites of OAuth consent screen, can proceed to securing credentials.

Screenshot of Google credentials tab

Fields to consider:

Application type Authorized redirect URI
Web application https://start-django.fly.dev/accounts/google/login/callback/

Submit to get Client id and Client secret