dabla commented on code in PR #59411:
URL: https://github.com/apache/airflow/pull/59411#discussion_r2637794325


##########
providers/keycloak/src/airflow/providers/keycloak/auth_manager/routes/token.py:
##########
@@ -36,8 +44,16 @@
     status_code=status.HTTP_201_CREATED,
     responses=create_openapi_http_exception_doc([status.HTTP_400_BAD_REQUEST, 
status.HTTP_401_UNAUTHORIZED]),
 )
-def create_token(body: TokenBody) -> TokenResponse:
-    token = create_token_for(body.username, body.password)
+def create_token(
+    body: TokenBody,
+) -> TokenResponse:
+    credentials = body.root
+    if isinstance(credentials, TokenPasswordBody):

Review Comment:
   Then you could just do something like this:
   
   ```
   def create_token(
       body: TokenBody,
   ) -> TokenResponse:
       token = body.create_token_for()  # if not supported, the default 
implementation will raise the ValueError, otherwise we get the token 
independently of the specialized TokenBody implementation.
       return TokenResponse(access_token=token)
   ```



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