{"record":{"id":"08fd1be7f7d1579c","repo":"router-for-me/CLIProxyAPI","slug":"no-authorization-code-received","errorCode":null,"errorMessage":"No authorization code received","messagePattern":"No authorization code received","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/auth/claude/oauth_server.go","lineNumber":200,"sourceCode":"\n\t// Validate required parameters\n\tif errorParam != \"\" {\n\t\tlog.Errorf(\"OAuth error received: %s\", errorParam)\n\t\tresult := &OAuthResult{\n\t\t\tError: errorParam,\n\t\t}\n\t\ts.sendResult(result)\n\t\thttp.Error(w, fmt.Sprintf(\"OAuth error: %s\", errorParam), http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif code == \"\" {\n\t\tlog.Error(\"No authorization code received\")\n\t\tresult := &OAuthResult{\n\t\t\tError: \"no_code\",\n\t\t}\n\t\ts.sendResult(result)\n\t\thttp.Error(w, \"No authorization code received\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\tif state == \"\" {\n\t\tlog.Error(\"No state parameter received\")\n\t\tresult := &OAuthResult{\n\t\t\tError: \"no_state\",\n\t\t}\n\t\ts.sendResult(result)\n\t\thttp.Error(w, \"No state parameter received\", http.StatusBadRequest)\n\t\treturn\n\t}\n\n\t// Send successful result\n\tresult := &OAuthResult{\n\t\tCode:  code,\n\t\tState: state,\n\t}","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/claude/oauth_server.go#L182-L218","documentation":"The Claude OAuth callback request carried no error but also no code query parameter, so there is no authorization code to exchange. The handler sends OAuthResult{Error: \"no_code\"} and returns HTTP 400 \"No authorization code received\".","triggerScenarios":"GET /callback with only ?state=xyz, with unrelated params, or with the code stripped/mangled by a proxy or manual URL editing; a redirect_uri mismatch that makes the provider omit the code.","commonSituations":"Manually pasting the callback URL minus query args; corporate proxies or browsers truncating long query strings; antivirus/link-scanners prefetching the callback URL and consuming/strip-mining parameters (Slack/Teams chat link previews are a classic); wrong redirect URI registered so the provider redirects without code.","solutions":["Re-run login and let the browser hit the callback untouched; don't copy/paste the URL manually","Register the exact callback URL (host+port+path) shown by the CLI in the provider app settings","Keep the callback port free of other services and avoid opening the auth link through link-preview-scanning chat tools"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// If you control the callback URL (e.g. testing), validate params first:\nq := u.Query()\nif q.Get(\"error\") == \"\" && q.Get(\"code\") == \"\" {\n    return errors.New(\"callback URL missing code parameter\")\n}","typeGuard":"func callbackHasCode(u *url.URL) bool { return u.Query().Get(\"code\") != \"\" }","tryCatchPattern":"result, err := server.WaitForCode(ctx)\nif err == nil && result.Error == \"no_code\" { /* restart login; check redirect URI and proxies */ }","preventionTips":["Never open auth links through chat apps that prefetch URLs","Match the registered redirect URI exactly, including port","Reserve the callback port for the CLI during login"],"tags":["claude","oauth","authorization-code","callback"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}