Fokko commented on code in PR #32786:
URL: https://github.com/apache/airflow/pull/32786#discussion_r1279263790


##########
airflow/providers/tabular/hooks/tabular.py:
##########
@@ -75,19 +77,25 @@ def test_connection(self) -> tuple[bool, str]:
         except Exception as e:
             return False, str(e)
 
-    def get_conn(self) -> str:
-        """Obtain a short-lived access token via a client_id and 
client_secret."""
+    def load_rest_catalog(self) -> Catalog:
         conn = self.get_connection(self.conn_id)
         base_url = conn.host if conn.host else DEFAULT_TABULAR_URL
         base_url = base_url.rstrip("/")
         client_id = conn.login
         client_secret = conn.password
-        data = {"client_id": client_id, "client_secret": client_secret, 
"grant_type": "client_credentials"}
 
-        response = requests.post(f"{base_url}/{TOKENS_ENDPOINT}", data=data)
-        response.raise_for_status()
+        properties = {
+            "type": "rest",
+            "uri": base_url,
+            "credential": f"{client_id}:{client_secret}",
+            "warehouse": conn.schema,
+        }
+        return load_catalog(self.conn_id, **properties)
 
-        return response.json()["access_token"]
+    def get_conn(self) -> str:
+        """Obtain a short-lived access token via a client_id and 
client_secret."""
+        cat = self.load_rest_catalog()

Review Comment:
   The PyIceberg library does the same call as this PR, so I think it is better 
to reuse that. It does not change any behavior, that's why I added 
`load_rest_catalog` in a separate function.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to