Refactor auth error handling in auth_callback to improve clarity and change status code to 400

This commit is contained in:
AlexSze 2026-04-24 18:40:31 +08:00
parent f7406b441f
commit d9b264ba13

View file

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