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


##########
providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/login.py:
##########
@@ -70,3 +70,38 @@ 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) -> RedirectResponse:
+    """Refresh the token."""
+    client = KeycloakAuthManager.get_keycloak_client()
+    redirect_uri = request.url_for("refresh_callback")
+    auth_url = client.auth_url(redirect_uri=str(redirect_uri), scope="openid")
+    return RedirectResponse(auth_url)
+
+
+@login_router.get("/refresh_callback")
+def refresh_callback(request: Request):
+    code = request.query_params.get("code")
+    if not code:
+        return HTMLResponse("Missing code", status_code=400)
+    client = KeycloakAuthManager.get_keycloak_client()
+    redirect_uri = request.url_for("refresh_callback")

Review Comment:
   It should be simpler than that. It can be achieved with:
   
   ```
   response = client.refresh_token(<refresh_token>)
   access_token = token_response["access_token"]
   new_refresh_token = token_response["refresh_token"]
   ```
   
   You do not need 2 routes for that. Just one.



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