authentik.sources.oauth.types.google

Google OAuth Views

 1"""Google OAuth Views"""
 2
 3from typing import Any
 4
 5from authentik.sources.oauth.models import AuthorizationCodeAuthMethod
 6from authentik.sources.oauth.types.registry import SourceType, registry
 7from authentik.sources.oauth.views.redirect import OAuthRedirect
 8
 9
10class GoogleOAuthRedirect(OAuthRedirect):
11    """Google OAuth2 Redirect"""
12
13    def get_additional_parameters(self, source):  # pragma: no cover
14        return {
15            "scope": ["email", "profile"],
16        }
17
18
19@registry.register()
20class GoogleType(SourceType):
21    """Google Type definition"""
22
23    redirect_view = GoogleOAuthRedirect
24    verbose_name = "Google"
25    name = "google"
26
27    authorization_url = "https://accounts.google.com/o/oauth2/auth"
28    access_token_url = "https://oauth2.googleapis.com/token"  # nosec
29    profile_url = "https://www.googleapis.com/oauth2/v1/userinfo"
30    oidc_well_known_url = "https://accounts.google.com/.well-known/openid-configuration"
31    oidc_jwks_url = "https://www.googleapis.com/oauth2/v3/certs"
32
33    authorization_code_auth_method = AuthorizationCodeAuthMethod.POST_BODY
34
35    def get_base_user_properties(self, info: dict[str, Any], **kwargs) -> dict[str, Any]:
36        return {
37            "email": info.get("email"),
38            "name": info.get("name"),
39        }
class GoogleOAuthRedirect(authentik.sources.oauth.views.redirect.OAuthRedirect):
11class GoogleOAuthRedirect(OAuthRedirect):
12    """Google OAuth2 Redirect"""
13
14    def get_additional_parameters(self, source):  # pragma: no cover
15        return {
16            "scope": ["email", "profile"],
17        }

Google OAuth2 Redirect

def get_additional_parameters(self, source):
14    def get_additional_parameters(self, source):  # pragma: no cover
15        return {
16            "scope": ["email", "profile"],
17        }

Return additional redirect parameters for this source.

@registry.register()
class GoogleType(authentik.sources.oauth.types.registry.SourceType):
20@registry.register()
21class GoogleType(SourceType):
22    """Google Type definition"""
23
24    redirect_view = GoogleOAuthRedirect
25    verbose_name = "Google"
26    name = "google"
27
28    authorization_url = "https://accounts.google.com/o/oauth2/auth"
29    access_token_url = "https://oauth2.googleapis.com/token"  # nosec
30    profile_url = "https://www.googleapis.com/oauth2/v1/userinfo"
31    oidc_well_known_url = "https://accounts.google.com/.well-known/openid-configuration"
32    oidc_jwks_url = "https://www.googleapis.com/oauth2/v3/certs"
33
34    authorization_code_auth_method = AuthorizationCodeAuthMethod.POST_BODY
35
36    def get_base_user_properties(self, info: dict[str, Any], **kwargs) -> dict[str, Any]:
37        return {
38            "email": info.get("email"),
39            "name": info.get("name"),
40        }

Google Type definition

redirect_view = <class 'GoogleOAuthRedirect'>
verbose_name = 'Google'
name = 'google'
authorization_url = 'https://accountsauthentik.sources.oauth.types.google.com/o/oauth2/auth'
access_token_url = 'https://oauth2.googleapis.com/token'
profile_url = 'https://www.googleapis.com/oauth2/v1/userinfo'
oidc_well_known_url = 'https://accountsauthentik.sources.oauth.types.google.com/.well-known/openid-configuration'
oidc_jwks_url = 'https://www.googleapis.com/oauth2/v3/certs'
authorization_code_auth_method = AuthorizationCodeAuthMethod.POST_BODY
def get_base_user_properties(self, info: dict[str, typing.Any], **kwargs) -> dict[str, typing.Any]:
36    def get_base_user_properties(self, info: dict[str, Any], **kwargs) -> dict[str, Any]:
37        return {
38            "email": info.get("email"),
39            "name": info.get("name"),
40        }

Get base user properties for enrollment/update