bugraoz93 commented on code in PR #51657:
URL: https://github.com/apache/airflow/pull/51657#discussion_r2160062506


##########
providers/keycloak/src/airflow/providers/keycloak/auth_manager/keycloak_auth_manager.py:
##########
@@ -282,3 +289,47 @@ def _get_headers(access_token):
             "Authorization": f"Bearer {access_token}",
             "Content-Type": "application/x-www-form-urlencoded",
         }
+
+    @classmethod
+    def _get_keycloak_client(cls) -> KeycloakOpenID:
+        client_id = conf.get(CONF_SECTION_NAME, CONF_CLIENT_ID_KEY)
+        client_secret = conf.get(CONF_SECTION_NAME, CONF_CLIENT_SECRET_KEY)
+        realm = conf.get(CONF_SECTION_NAME, CONF_REALM_KEY)
+        server_url = conf.get(CONF_SECTION_NAME, CONF_SERVER_URL_KEY)
+
+        return KeycloakOpenID(
+            server_url=server_url,
+            client_id=client_id,
+            client_secret_key=client_secret,
+            realm_name=realm,
+        )
+
+    def refresh_token(self, token: str) -> str | None:
+        """Refresh the access token for the user."""
+        client = self._get_keycloak_client()
+        try:
+            tokens = client.refresh_token(token)
+            log.info("Token refreshed successfully")
+            return tokens["access_token"]
+        except InvalidTokenError:
+            log.error("Invalid refresh token")
+            return None
+        except Exception as e:
+            log.error("Error refreshing token: %s", e)
+            return None
+
+    def get_user_from_code(self, code: str, redirect_uri: str) -> 
KeycloakAuthManagerUser:

Review Comment:
   Removed, indeed we don't need it



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to