BerriAI/litellm · error · HTTPException

response_type must be 'code'

Error message

response_type must be 'code'

What it means

HTTP 400 on the BYOK authorize GET/POST: response_type is anything other than 'code'. The mini OAuth server only implements the authorization-code flow, so any other response_type is rejected up front.

Source

Thrown at litellm/proxy/_experimental/mcp_server/byok_oauth_endpoints.py:654

    redirect_uri: str | None = None,
    response_type: str | None = None,
    code_challenge: str | None = None,
    code_challenge_method: str | None = None,
    state: str | None = None,
    server_id: str | None = None,
) -> HTMLResponse:
    """
    Show the BYOK API-key entry form.

    The MCP client navigates the user here; the user types their API key and
    clicks "Connect & Authorize", which POSTs back to this same path.

    This GET is intentionally unauthenticated: it only renders HTML with no
    state change. The POST handler enforces ``user_api_key_auth`` and pins
    the stored credential to the authenticated session.
    """
    if response_type != "code":
        raise HTTPException(status_code=400, detail="response_type must be 'code'")
    if not redirect_uri:
        raise HTTPException(status_code=400, detail="redirect_uri is required")
    # Validate here too so the user sees the rejection before typing their
    # API key into the HTML form (the POST handler also validates).
    validate_loopback_redirect_uri(redirect_uri)
    if not code_challenge:
        raise HTTPException(status_code=400, detail="code_challenge is required")

    # Resolve server metadata (name, description items, help URL).
    server_name = "MCP Server"
    access_items: list = []
    help_url = ""
    if server_id:
        try:
            from litellm.proxy._experimental.mcp_server.mcp_server_manager import (
                global_mcp_server_manager,
            )

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use response_type=code; other response types are unsupported.

Example fix

?response_type=code&client_id=...
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/_experimental/mcp_server/byok_oauth_endpoints.py:654 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/5c96b7b7b5781a14. Report an issue: GitHub.