Skip to main content

exchange_token

Function exchange_token 

Source
pub async fn exchange_token(
    http: &OauthHttpClient,
    config: &TokenExchangeConfig,
    subject_token: &str,
) -> Result<ExchangedToken, McpxError>
Expand description

Exchange an inbound access token for a downstream access token via RFC 8693 token exchange.

The MCP server calls this to swap a user’s MCP-scoped JWT (subject_token) for a new JWT scoped to a downstream API identified by TokenExchangeConfig::audience.

§Errors

Returns an error if the HTTP request fails, the authorization server rejects the exchange, or the response cannot be parsed.