You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by am...@apache.org on 2025/04/19 08:45:49 UTC
(airflow) branch main updated: Fix mypy for get_oauth_token signature in SnowflakeSqlApiHook (#49449)
This is an automated email from the ASF dual-hosted git repository.
amoghdesai pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 78f00a33fa1 Fix mypy for get_oauth_token signature in SnowflakeSqlApiHook (#49449)
78f00a33fa1 is described below
commit 78f00a33fa1167295609283f47b0046413ae8d9a
Author: GPK <go...@gmail.com>
AuthorDate: Sat Apr 19 09:45:43 2025 +0100
Fix mypy for get_oauth_token signature in SnowflakeSqlApiHook (#49449)
---
.../src/airflow/providers/snowflake/hooks/snowflake_sql_api.py | 5 ++---
.../snowflake/tests/unit/snowflake/hooks/test_snowflake_sql_api.py | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake_sql_api.py b/providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake_sql_api.py
index 762f1b10991..1fe3e6cd83c 100644
--- a/providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake_sql_api.py
+++ b/providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake_sql_api.py
@@ -201,7 +201,7 @@ class SnowflakeSqlApiHook(SnowflakeHook):
if all(
[conn_config.get("refresh_token"), conn_config.get("client_id"), conn_config.get("client_secret")]
):
- oauth_token = self.get_oauth_token()
+ oauth_token = self.get_oauth_token(conn_config=conn_config)
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {oauth_token}",
@@ -232,9 +232,8 @@ class SnowflakeSqlApiHook(SnowflakeHook):
}
return headers
- def get_oauth_token(self) -> str:
+ def get_oauth_token(self, conn_config: dict[str, Any]) -> str:
"""Generate temporary OAuth access token using refresh token in connection details."""
- conn_config = self._get_conn_params
url = f"{self.account_identifier}.snowflakecomputing.com/oauth/token-request"
data = {
"grant_type": "refresh_token",
diff --git a/providers/snowflake/tests/unit/snowflake/hooks/test_snowflake_sql_api.py b/providers/snowflake/tests/unit/snowflake/hooks/test_snowflake_sql_api.py
index 1247e3e0318..efb47f0c9d2 100644
--- a/providers/snowflake/tests/unit/snowflake/hooks/test_snowflake_sql_api.py
+++ b/providers/snowflake/tests/unit/snowflake/hooks/test_snowflake_sql_api.py
@@ -364,7 +364,7 @@ class TestSnowflakeSqlApiHook:
requests_post.return_value.status_code = 200
mock_auth.return_value = BASIC_AUTH
hook = SnowflakeSqlApiHook(snowflake_conn_id="mock_conn_id")
- hook.get_oauth_token()
+ hook.get_oauth_token(CONN_PARAMS_OAUTH)
requests_post.assert_called_once_with(
f"https://{CONN_PARAMS_OAUTH['account']}.{CONN_PARAMS_OAUTH['region']}.snowflakecomputing.com/oauth/token-request",
data={