router-for-me/CLIProxyAPI · error
token refresh request failed: %w
Error message
token refresh request failed: %w
What it means
Error "token refresh request failed: %w" thrown in router-for-me/CLIProxyAPI.
Source
Thrown at internal/auth/claude/anthropic_auth.go:546
"grant_type": "refresh_token",
"refresh_token": refreshToken,
"scope": ClaudeOAuthScope,
}
jsonBody, err := json.Marshal(reqBody)
if err != nil {
return nil, fmt.Errorf("failed to marshal request body: %w", err)
}
req, err := http.NewRequestWithContext(ctx, "POST", RefreshTokenURL, strings.NewReader(string(jsonBody)))
if err != nil {
return nil, fmt.Errorf("failed to create refresh request: %w", err)
}
applyClaudeOAuthAxiosHeaders(req)
resp, err := o.httpClient.Do(req)
if err != nil {
return nil, fmt.Errorf("token refresh request failed: %w", err)
}
defer func() {
_ = resp.Body.Close()
}()
body, err := readClaudeOAuthResponseBody(resp)
if err != nil {
return nil, fmt.Errorf("failed to read refresh response: %w", err)
}
if resp.StatusCode != http.StatusOK {
message := string(body)
if resp.StatusCode == http.StatusTooManyRequests {
retryAfter := parseClaudeRetryAfter(resp)
setClaudeRefreshBlockedUntil(refreshToken, time.Now().Add(retryAfter))
return nil, &refreshHTTPError{status: resp.StatusCode, message: message, retryable: false}
}
return nil, &refreshHTTPError{View on GitHub (pinned to 78f0c4079e)
Solutions
- Check network connectivity to the token endpoint and retry the refresh.
- Inspect the wrapped error for DNS, TLS, or timeout failures.
When it happens
Trigger: Thrown at internal/auth/claude/anthropic_auth.go:546 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/f6ea10943801f716.
Report an issue: GitHub.