diff --git a/querybook/server/app/auth/auth0_auth.py b/querybook/server/app/auth/auth0_auth.py index e0ac60df5..02efeddc5 100644 --- a/querybook/server/app/auth/auth0_auth.py +++ b/querybook/server/app/auth/auth0_auth.py @@ -1,6 +1,8 @@ from env import get_env_config +import certifi from app.auth.okta_auth import OAUTH_CALLBACK_PATH, OktaLoginManager +from .utils import AuthenticationError class Auth0LoginManager(OktaLoginManager): @@ -11,6 +13,20 @@ def get_oauth_urls(self): profile_url = f"{auth0_base_url}/userinfo" return authorization_url, token_url, profile_url + def _fetch_access_token(self, code): + resp = self.oauth_session.fetch_token( + token_url=self.oauth_config["token_url"], + client_id=self.oauth_config["client_id"], + code=code, + client_secret=self.oauth_config["client_secret"], + cert=certifi.where(), + ) + + if resp is None: + raise AuthenticationError("Null response, denying access.") + return resp["access_token"] + + login_manager = Auth0LoginManager()