{"record":{"id":"a8448bd68f436332","repo":"router-for-me/CLIProxyAPI","slug":"failed-to-parse-token-response-w","errorCode":null,"errorMessage":"failed to parse token response: %w","messagePattern":"failed to parse token response: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/claude/anthropic_auth.go","lineNumber":429,"sourceCode":"\t\tif errClose := resp.Body.Close(); errClose != nil {\n\t\t\tlog.Errorf(\"failed to close response body: %v\", errClose)\n\t\t}\n\t}()\n\n\tbody, err := readClaudeOAuthResponseBody(resp)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read token response: %w\", err)\n\t}\n\t// log.Debugf(\"Token response: %s\", string(body))\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"token exchange failed with status %d: %s\", resp.StatusCode, string(body))\n\t}\n\t// log.Debugf(\"Token response: %s\", string(body))\n\n\tvar tokenResp tokenResponse\n\tif err = json.Unmarshal(body, &tokenResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse token response: %w\", err)\n\t}\n\n\tdeviceIDs, errDeviceIDs := GenerateDeviceIDPool()\n\tif errDeviceIDs != nil {\n\t\treturn nil, errDeviceIDs\n\t}\n\n\t// Create token data.\n\ttokenData := ClaudeTokenData{\n\t\tAccessToken:      tokenResp.AccessToken,\n\t\tRefreshToken:     tokenResp.RefreshToken,\n\t\tEmail:            tokenResp.Account.EmailAddress,\n\t\tAccountUUID:      tokenResp.Account.UUID,\n\t\tOrganizationUUID: tokenResp.Organization.UUID,\n\t\tOrganizationName: tokenResp.Organization.Name,\n\t\tExpire:           time.Now().Add(time.Duration(tokenResp.ExpiresIn) * time.Second).Format(time.RFC3339),\n\t}\n","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/claude/anthropic_auth.go#L411-L447","documentation":"Error \"failed to parse token response: %w\" thrown in router-for-me/CLIProxyAPI.","triggerScenarios":"Thrown at internal/auth/claude/anthropic_auth.go:429 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"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-15T17:31:12.345Z"}