authentik.sources.oauth.types.facebook
Facebook OAuth Views
1"""Facebook 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 FacebookOAuthRedirect(OAuthRedirect): 11 """Facebook OAuth2 Redirect""" 12 13 def get_additional_parameters(self, source): # pragma: no cover 14 return { 15 "scope": ["email"], 16 } 17 18 19@registry.register() 20class FacebookType(SourceType): 21 """Facebook Type definition""" 22 23 redirect_view = FacebookOAuthRedirect 24 verbose_name = "Facebook" 25 name = "facebook" 26 27 authorization_url = "https://www.facebook.com/v7.0/dialog/oauth" 28 access_token_url = "https://graph.facebook.com/v7.0/oauth/access_token" # nosec 29 profile_url = "https://graph.facebook.com/v7.0/me?fields=id,name,email" 30 31 authorization_code_auth_method = AuthorizationCodeAuthMethod.POST_BODY 32 33 def get_base_user_properties(self, info: dict[str, Any], **kwargs) -> dict[str, Any]: 34 return { 35 "username": info.get("name"), 36 "email": info.get("email"), 37 "name": info.get("name"), 38 }
11class FacebookOAuthRedirect(OAuthRedirect): 12 """Facebook OAuth2 Redirect""" 13 14 def get_additional_parameters(self, source): # pragma: no cover 15 return { 16 "scope": ["email"], 17 }
Facebook OAuth2 Redirect
20@registry.register() 21class FacebookType(SourceType): 22 """Facebook Type definition""" 23 24 redirect_view = FacebookOAuthRedirect 25 verbose_name = "Facebook" 26 name = "facebook" 27 28 authorization_url = "https://www.facebook.com/v7.0/dialog/oauth" 29 access_token_url = "https://graph.facebook.com/v7.0/oauth/access_token" # nosec 30 profile_url = "https://graph.facebook.com/v7.0/me?fields=id,name,email" 31 32 authorization_code_auth_method = AuthorizationCodeAuthMethod.POST_BODY 33 34 def get_base_user_properties(self, info: dict[str, Any], **kwargs) -> dict[str, Any]: 35 return { 36 "username": info.get("name"), 37 "email": info.get("email"), 38 "name": info.get("name"), 39 }
Facebook Type definition
redirect_view =
<class 'FacebookOAuthRedirect'>
access_token_url =
'https://graphauthentik.sources.oauth.types.facebook.com/v7.0/oauth/access_token'
profile_url =
'https://graphauthentik.sources.oauth.types.facebook.com/v7.0/me?fields=id,name,email'
def
get_base_user_properties(self, info: dict[str, typing.Any], **kwargs) -> dict[str, typing.Any]:
34 def get_base_user_properties(self, info: dict[str, Any], **kwargs) -> dict[str, Any]: 35 return { 36 "username": info.get("name"), 37 "email": info.get("email"), 38 "name": info.get("name"), 39 }
Get base user properties for enrollment/update