pub async fn session_exchange(
http_client: &Client,
protected_resource_base: &str,
access_token: &str,
) -> Result<ATProtocolSession>Expand description
Exchanges an OAuth access token for an AT Protocol session.
This function takes an OAuth access token and exchanges it for a full AT Protocol session, which includes additional information like the user’s DID, handle, and PDS endpoint. This is specific to AT Protocol’s OAuth implementation.
This is a convenience function that calls session_exchange_with_options
with no additional options.
§Arguments
http_client- The HTTP client to use for making requestsprotected_resource_base- The base URL of the protected resource (PDS)access_token- The OAuth access token to exchange
§Returns
Returns an ATProtocolSession with full session information,
or an error if the session exchange fails.
§Example
use atproto_oauth_aip::workflow::session_exchange;
let session = session_exchange(
&http_client,
protected_resource,
access_token,
).await?;
println!("Authenticated as {} ({})", session.handle, session.did);
println!("PDS endpoint: {}", session.pds_endpoint);