Skip to content

Commit

Permalink
Set grant type of the Tabular hook (#25099)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fokko committed Jul 15, 2022
1 parent f611b1f commit 84b6799
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions airflow/providers/tabular/hooks/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_connection(self) -> Tuple[bool, str]:
self.get_conn()
return True, "Successfully fetched token from Tabular"
except HTTPError as e:
return False, f"HTTP Error: {e}"
return False, f"HTTP Error: {e}: {e.response.text}"
except Exception as e:
return False, str(e)

Expand All @@ -79,10 +79,9 @@ def get_conn(self) -> str:
base_url = base_url.rstrip('/')
client_id = conn.login
client_secret = conn.password
headers = {"Content-Type": "application/x-www-form-urlencoded"}
data = {"client_id": client_id, "client_secret": client_secret}
data = {"client_id": client_id, "client_secret": client_secret, "grant_type": "client_credentials"}

response = requests.post(f"{base_url}/{TOKENS_ENDPOINT}", data=data, headers=headers)
response = requests.post(f"{base_url}/{TOKENS_ENDPOINT}", data=data)
response.raise_for_status()

return response.json()["access_token"]
Expand Down

0 comments on commit 84b6799

Please sign in to comment.