hussein-awala commented on code in PR #32673:
URL: https://github.com/apache/airflow/pull/32673#discussion_r1267155203


##########
airflow/providers/google/cloud/hooks/kubernetes_engine.py:
##########
@@ -387,8 +387,15 @@ def get_xcom_sidecar_container_resources(self):
 
     def get_conn(self) -> client.ApiClient:
         configuration = self._get_config()
+        configuration.refresh_api_key_hook = self._refresh_api_key_hook
         return client.ApiClient(configuration)
 
+    def _refresh_api_key_hook(self, configuration: 
client.configuration.Configuration):
+        creds = self.get_credentials()
+        if not GKEPodHook._is_credentials_valid(creds):
+            GKEPodHook._refresh_token(creds)
+            configuration.api_key = {"authorization": creds.token}

Review Comment:
   You could always set the api_key and use the `_get_token` method, which 
return the old api_key if it is still valid and a new one if not.
   ```suggestion
           configuration.api_key = {"authorization": 
self._get_token(self.get_credentials())}
   ```



-- 
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