{"record":{"id":"0de737e8195da344","repo":"router-for-me/CLIProxyAPI","slug":"no-authorization-code-received-0de737","errorCode":null,"errorMessage":"No authorization code received","messagePattern":"No authorization code received","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/auth/codex/oauth_server.go","lineNumber":197,"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":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/codex/oauth_server.go#L179-L215","documentation":"The Codex OAuth callback request contained neither error nor code query parameters, so no authorization code exists to exchange for tokens. The handler sends OAuthResult{Error: \"no_code\"} and returns HTTP 400 \"No authorization code received\".","triggerScenarios":"GET /callback with empty/absent code (?state only, bare path, or code renamed/removed); prefetchers hitting the callback URL before the real browser redirect.","commonSituations":"Chat clients (Slack/Teams) or security tools prefetching the loopback callback link and stripping parameters; redirect URI mismatch causing the provider to omit code; manual URL editing during debugging; port conflicts so the callback lands on the wrong local server.","solutions":["Re-run the login flow and open the auth URL directly in a browser, not through chat/email preview layers","Confirm the exact redirect URI (including port from --oauth-callback-port) matches the app registration","Free the callback port from other processes before starting login"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"u, err := url.Parse(callbackURL)\nif err == nil && u.Query().Get(\"error\") == \"\" && u.Query().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; verify redirect URI, port, and no prefetching middlemen */ }","preventionTips":["Open the Codex auth URL directly in a browser","Ensure --oauth-callback-port matches the registered redirect URI","Keep the callback port exclusive to the CLI during login"],"tags":["codex","oauth","authorization-code","callback"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}