Hmbown/CodeWhale · error · anyhow
OAuth provider did not return credentials
Error message
OAuth provider did not return credentials
What it means
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.
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
Defensive patterns
Strategy: try-catch
Try / catch
match complete_oauth_flow(server) {
Err(e) if e.to_string().contains("did not return credentials") => {
// state lost or exchange skipped: clear state and restart the flow
clear_oauth_state(server);
reauthenticate(server)?;
}
other => other?,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- agy OAuth token JSON carries no access token member
- agy OAuth token member
- atomically replacing xAI OAuth credentials
- bearer credentials are not an API key
- Codewhale-owned OAuth credentials at
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/ea3435a43798c1b1.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/mcp/oauth.rs:1706
CallbackResult::Error(error) => return Err(anyhow!(error)),
};
// RFC 9207: servers that advertise
// `authorization_response_iss_parameter_supported` send `iss` on the
// redirect and rmcp requires it back; forward it so the callback binds
// to the discovered issuer instead of failing as "missing".
self.oauth_state
.handle_callback_with_issuer(&code, &state, issuer.as_deref())
.await
.context("handling MCP OAuth callback")?;
let (client_id, credentials) = self
.oauth_state
.get_credentials()
.await
.context("reading MCP OAuth credentials")?;
let credentials =
credentials.ok_or_else(|| anyhow!("OAuth provider did not return credentials"))?;
let stored = StoredMcpOAuthTokens {
server_name: self.server_name.clone(),
url: self.server_url.clone(),
client_id,
expires_at: compute_expires_at_millis(&credentials),
token_response: WrappedOAuthTokenResponse(credentials),
};
save_oauth_tokens(&stored)
}
.await;
drop(self.guard);
result
}
}
async fn start_authorization(
server_url: &str,View on GitHub (pinned to 73e0f67d83)