From a5c24599e90ae9626eb387fe0838367fff64c220 Mon Sep 17 00:00:00 2001 From: Ukang'a Dickson Date: Wed, 16 Sep 2020 13:04:16 +0300 Subject: [PATCH] Check first if Custom-Api-Token headers is set. --- superset_patchup/oauth.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/superset_patchup/oauth.py b/superset_patchup/oauth.py index 6bbdbea..3e06397 100644 --- a/superset_patchup/oauth.py +++ b/superset_patchup/oauth.py @@ -116,9 +116,11 @@ def oauth_authorized(self, provider): """View that a user is redirected to from the Oauth server""" logging.debug("Authorized init") - resp = self.appbuilder.sm.oauth_remotes[provider].authorize_access_token() if "Custom-Api-Token" in request.headers: + logging.debug("Custom-Api-Token is present") resp = {"access_token": request.headers.get("Custom-Api-Token")} + else: + resp = self.appbuilder.sm.oauth_remotes[provider].authorize_access_token() if resp is None: flash("You denied the request to sign in.", "warning") return redirect("/login")