Sample auth settings for google oauth

I would like to enable signing in with google workspace accounts (institutional accounts). The only topic that discuss this is this topic:

and I couldn’t figure out how to make the settings for Google Oauth. Is there a sample settings/steps that can be followed easily to achieve this?

Google uses OpenID-Connect (OIDC) nowadays: OpenID Connect  |  Google Identity  |  Google Developers

This should be pretty straightfoward to use with the authlib auth/identity provider type:

AUTH_PROVIDERS = {
    'google': {
        'type': 'authlib',
        'title': 'Google',
        'authlib_args': {
            'client_id': 'xxx',
            'client_secret': 'xxx',
            'server_metadata_url': 'https://accounts.google.com/.well-known/openid-configuration',
            'client_kwargs': {'scope': 'openid profile email'}
        },
        'callback_uri': '/authlib/google',
        'use_id_token': True,
    },
}

IDENTITY_PROVIDERS = {
    'google': {
        'type': 'authlib',
        'title': 'Google',
        'mapping': {
            'first_name': 'given_name',
            'last_name': 'family_name',
        }
    },
}
1 Like

@ThiefMaster Thank you very much. It’s working now. It took some time to find out that I also need to pip install authlib, thanks to you as well in this post: