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


##########
providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/login.py:
##########
@@ -70,3 +72,25 @@ def login_callback(request: Request):
     secure = bool(conf.get("api", "ssl_cert", fallback=""))
     response.set_cookie(COOKIE_NAME_JWT_TOKEN, token, secure=secure)
     return response
+
+
+@login_router.get("/refresh")
+def refresh(
+    request: Request, user: Annotated[KeycloakAuthManagerUser, 
Depends(get_user)]
+) -> RedirectResponse:
+    """Refresh the token."""
+    client = KeycloakAuthManager.get_keycloak_client()
+
+    if not user or not user.refresh_token:
+        raise HTTPException(status_code=400, detail="User is empty or has no 
refresh token")
+
+    tokens = client.refresh_token(user.refresh_token)
+    user.refresh_token = tokens["refresh_token"]

Review Comment:
   True, else we are just making calls and will end up with errors with 
access_token :) Nice one, missed this while minimising the solution 
:sweat_smile:  



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