{"record":{"id":"f6ea10943801f716","repo":"router-for-me/CLIProxyAPI","slug":"token-refresh-request-failed-w","errorCode":null,"errorMessage":"token refresh request failed: %w","messagePattern":"token refresh request failed: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/claude/anthropic_auth.go","lineNumber":546,"sourceCode":"\t\t\"grant_type\":    \"refresh_token\",\n\t\t\"refresh_token\": refreshToken,\n\t\t\"scope\":         ClaudeOAuthScope,\n\t}\n\n\tjsonBody, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to marshal request body: %w\", err)\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", RefreshTokenURL, strings.NewReader(string(jsonBody)))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create refresh request: %w\", err)\n\t}\n\tapplyClaudeOAuthAxiosHeaders(req)\n\n\tresp, err := o.httpClient.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"token refresh request failed: %w\", err)\n\t}\n\tdefer func() {\n\t\t_ = resp.Body.Close()\n\t}()\n\n\tbody, err := readClaudeOAuthResponseBody(resp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read refresh response: %w\", err)\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tmessage := string(body)\n\t\tif resp.StatusCode == http.StatusTooManyRequests {\n\t\t\tretryAfter := parseClaudeRetryAfter(resp)\n\t\t\tsetClaudeRefreshBlockedUntil(refreshToken, time.Now().Add(retryAfter))\n\t\t\treturn nil, &refreshHTTPError{status: resp.StatusCode, message: message, retryable: false}\n\t\t}\n\t\treturn nil, &refreshHTTPError{","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/claude/anthropic_auth.go#L528-L564","documentation":"Error \"token refresh request failed: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/claude/anthropic_auth.go:546 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check network connectivity to the token endpoint and retry the refresh.","Inspect the wrapped error for DNS, TLS, or timeout failures."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}