BerriAI/litellm · error · HTTPException
redirect_uri is required
Error message
redirect_uri is required
What it means
Raised in the BYOK OAuth authorize GET handler when the query string carries no redirect_uri parameter. The OAuth flow requires the MCP client to declare where the authorization code should be sent back; without it the handler cannot build the redirect and aborts before rendering the API-key entry form.
Source
Thrown at litellm/proxy/_experimental/mcp_server/byok_oauth_endpoints.py:656
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,
)
registry: Final = global_mcp_server_manager.get_registry()
if server_id in registry:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Include redirect_uri in the authorization request.
Example fix
&redirect_uri=https://client.example/callback
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/_experimental/mcp_server/byok_oauth_endpoints.py:656 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/b4e257cfffd9ca4f.
Report an issue: GitHub.