router-for-me/CLIProxyAPI · error
failed to parse token response: %w
Error message
failed to parse token response: %w
What it means
Error "failed to parse token response: %w" thrown in router-for-me/CLIProxyAPI.
Source
Thrown at internal/auth/claude/anthropic_auth.go:429
if errClose := resp.Body.Close(); errClose != nil {
log.Errorf("failed to close response body: %v", errClose)
}
}()
body, err := readClaudeOAuthResponseBody(resp)
if err != nil {
return nil, fmt.Errorf("failed to read token response: %w", err)
}
// log.Debugf("Token response: %s", string(body))
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("token exchange failed with status %d: %s", resp.StatusCode, string(body))
}
// log.Debugf("Token response: %s", string(body))
var tokenResp tokenResponse
if err = json.Unmarshal(body, &tokenResp); err != nil {
return nil, fmt.Errorf("failed to parse token response: %w", err)
}
deviceIDs, errDeviceIDs := GenerateDeviceIDPool()
if errDeviceIDs != nil {
return nil, errDeviceIDs
}
// Create token data.
tokenData := ClaudeTokenData{
AccessToken: tokenResp.AccessToken,
RefreshToken: tokenResp.RefreshToken,
Email: tokenResp.Account.EmailAddress,
AccountUUID: tokenResp.Account.UUID,
OrganizationUUID: tokenResp.Organization.UUID,
OrganizationName: tokenResp.Organization.Name,
Expire: time.Now().Add(time.Duration(tokenResp.ExpiresIn) * time.Second).Format(time.RFC3339),
}
View on GitHub (pinned to 78f0c4079e)
Solutions
- Verify the token endpoint returned valid JSON; inspect the wrapped parse error.
- Check for an HTML error page from a proxy being returned instead of JSON.
When it happens
Trigger: Thrown at internal/auth/claude/anthropic_auth.go:429 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/a8448bd68f436332.
Report an issue: GitHub.