pub async fn exchange_authorization_code(
auth: &OAuthAuth,
client: &HttpClient,
code: &str,
code_verifier: &str,
) -> Result<(String, Option<u64>), SendraError>Expand description
A code exchanged for exchange_authorization_code, obtained interactively
(see the module doc comment) rather than from auth.oauth itself, so it
cannot travel through OAuthAuth the way every other grant’s fields do.
Trades code (plus the PKCE code_verifier matching the code_challenge
build_authorization_url sent) for a token, via the standard
authorization_code token request (RFC 6749 §4.1.3): POST auth.token_url with grant_type=authorization_code, code,
redirect_uri, client_id, code_verifier, and client_secret when
auth has one — reusing send_prepared through the same shared
HttpClient every other request in the run sends through, exactly like
[acquire_fresh] does for the other two grants.
This is a standalone entry point, not folded into acquire_token: it is
driven by a front end that already has a code in hand from its own
browser/callback-listener flow, not by the automatic “acquire whatever
this oauth: config needs” path every other grant uses. Once this
succeeds, the caller is expected to hand the result to
OAuthTokenCache::insert_token so later automatic resolution reuses it
— see the module doc comment.
Errors exactly like acquire_token does: a non-2xx response or an
unparseable body is SendraError::OAuthAcquisition naming
auth.token_url and why; so is a network/timeout failure reaching it.