pub async fn exchange_code(
params: ExchangeCode,
http: &dyn HttpClient,
) -> Result<TokenResponse>Available on non-WebAssembly only.
Expand description
Exchange authorization code for tokens
This is a server-only function that exchanges an authorization code for access token, refresh token (optional), and ID token (if openid scope).
ยงExample
let http = ReqwestHttpClient::default();
let tokens = exchange_code(ExchangeCode {
issuer: "https://auth.example.com".into(),
client_id: "my-client".into(),
code: "auth_code".into(),
redirect_uri: "https://app.example.com/callback".into(),
code_verifier: Some("pkce_verifier".into()),
client_secret: None, // For public clients
token_endpoint_auth_method: None,
}, &http).await?;