{"record":{"id":"ea3435a43798c1b1","repo":"Hmbown/CodeWhale","slug":"oauth-provider-did-not-return-credentials","errorCode":null,"errorMessage":"OAuth provider did not return credentials","messagePattern":"OAuth provider did not return credentials","errorType":"exception","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp/oauth.rs","lineNumber":1706,"sourceCode":"                CallbackResult::Error(error) => return Err(anyhow!(error)),\n            };\n\n            // RFC 9207: servers that advertise\n            // `authorization_response_iss_parameter_supported` send `iss` on the\n            // redirect and rmcp requires it back; forward it so the callback binds\n            // to the discovered issuer instead of failing as \"missing\".\n            self.oauth_state\n                .handle_callback_with_issuer(&code, &state, issuer.as_deref())\n                .await\n                .context(\"handling MCP OAuth callback\")?;\n\n            let (client_id, credentials) = self\n                .oauth_state\n                .get_credentials()\n                .await\n                .context(\"reading MCP OAuth credentials\")?;\n            let credentials =\n                credentials.ok_or_else(|| anyhow!(\"OAuth provider did not return credentials\"))?;\n            let stored = StoredMcpOAuthTokens {\n                server_name: self.server_name.clone(),\n                url: self.server_url.clone(),\n                client_id,\n                expires_at: compute_expires_at_millis(&credentials),\n                token_response: WrappedOAuthTokenResponse(credentials),\n            };\n            save_oauth_tokens(&stored)\n        }\n        .await;\n\n        drop(self.guard);\n        result\n    }\n}\n\nasync fn start_authorization(\n    server_url: &str,","sourceCodeStart":1688,"sourceCodeEnd":1724,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp/oauth.rs#L1688-L1724","documentation":"After an OAuth flow completes, the client reads credentials from its OAuth state via get_credentials(); a well-behaved provider must return Some(credentials). If the state reports success but yields None, this error signals an internal broken invariant — the provider finished the exchange without actually producing an access token. The context 'reading MCP OAuth credentials' wraps any underlying read failure.","triggerScenarios":"The post-authorization credential read path (oauth_state.get_credentials() returning Ok(None)) — e.g. the OAuth callback completed but the token exchange never stored a result, or the state was cleared/reset between the callback and the read.","commonSituations":"OAuth server returned an authorization code but the token exchange silently failed or was skipped; state store reset by a concurrent session; provider bug returning an empty credential set.","solutions":["Re-run the OAuth authentication flow for the MCP server to complete a fresh token exchange","Check server logs for a failed token exchange preceding this error","Clear any stale OAuth state for the server and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match complete_oauth_flow(server) {\n    Err(e) if e.to_string().contains(\"did not return credentials\") => {\n        // state lost or exchange skipped: clear state and restart the flow\n        clear_oauth_state(server);\n        reauthenticate(server)?;\n    }\n    other => other?,\n}","preventionTips":["Re-run the full OAuth flow rather than retrying reads against stale state","Avoid sharing or resetting OAuth state across concurrent sessions","Check the IdP's token exchange responses in logs during setup"],"tags":["oauth","credentials","mcp","state"],"backgroundTag":"missing-credentials","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}