router-for-me/CLIProxyAPI · error
PKCE codes are required
Error message
PKCE codes are required
What it means
Error "PKCE codes are required" thrown in router-for-me/CLIProxyAPI.
Source
Thrown at internal/auth/claude/anthropic_auth.go:321
}
return profile
}
// GenerateAuthURL creates the OAuth authorization URL with PKCE.
// This method generates a secure authorization URL including PKCE challenge codes
// for the OAuth2 flow with Anthropic's API.
//
// Parameters:
// - state: A random state parameter for CSRF protection
// - pkceCodes: The PKCE codes for secure code exchange
//
// Returns:
// - string: The complete authorization URL
// - string: The state parameter for verification
// - error: An error if PKCE codes are missing or URL generation fails
func (o *ClaudeAuth) GenerateAuthURL(state string, pkceCodes *PKCECodes) (string, string, error) {
if pkceCodes == nil {
return "", "", fmt.Errorf("PKCE codes are required")
}
params := url.Values{
"code": {"true"},
"client_id": {ClientID},
"response_type": {"code"},
"redirect_uri": {RedirectURI},
"scope": {ClaudeOAuthScope},
"code_challenge": {pkceCodes.CodeChallenge},
"code_challenge_method": {"S256"},
"state": {state},
}
authURL := fmt.Sprintf("%s?%s", AuthURL, params.Encode())
return authURL, state, nil
}
// parseCodeAndState extracts the authorization code and state from the callback response.View on GitHub (pinned to 78f0c4079e)
Solutions
- Provide both the PKCE code verifier and authorization code before continuing.
- Restart the OAuth flow so the PKCE codes are generated and retained.
When it happens
Trigger: Thrown at internal/auth/claude/anthropic_auth.go:321 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/4d241c57c19a6bb8.
Report an issue: GitHub.