Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set grant type of the Tabular hook #25099

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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