From d9b264ba139c71ebf0aad8eb16359aedc75fb42e Mon Sep 17 00:00:00 2001 From: AlexSze Date: Fri, 24 Apr 2026 18:40:31 +0800 Subject: [PATCH] Refactor auth error handling in auth_callback to improve clarity and change status code to 400 --- litellm/proxy/management_endpoints/ui_sso.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/management_endpoints/ui_sso.py b/litellm/proxy/management_endpoints/ui_sso.py index 2be0158c6cd..d35e65be9bb 100644 --- a/litellm/proxy/management_endpoints/ui_sso.py +++ b/litellm/proxy/management_endpoints/ui_sso.py @@ -1311,9 +1311,14 @@ async def auth_callback(request: Request, state: Optional[str] = None): # noqa: oauth_error = request.query_params.get("error") oauth_error_description = request.query_params.get("error_description") if oauth_error: + oauth_error_detail = f"OAuth error: {oauth_error}" + if oauth_error_description: + oauth_error_detail += ( + f", error_description: {oauth_error_description}" + ) raise HTTPException( - status_code=401, - detail=f"OAuth error: {oauth_error}, error_description: {oauth_error_description}", + status_code=400, + detail=oauth_error_detail, ) # Check if this is a CLI login (state starts with our CLI prefix)