pub async fn session_exchange_with_options(
http_client: &Client,
protected_resource_base: &str,
access_token: &str,
access_token_type: &Option<&str>,
subject: &Option<&str>,
) -> Result<ATProtocolSession>Expand description
Exchanges an OAuth access token for an AT Protocol session with additional options.
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 version allows specifying additional options for the session exchange.
§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 exchangeaccess_token_type- Optional token type (“oauth_session”, “app_password_session”, or “best”)subject- Optional subject (DID) to specify which user’s session to retrieve
§Returns
Returns an ATProtocolSession with full session information,
or an error if the session exchange fails.
§Example
use atproto_oauth_aip::workflow::session_exchange_with_options;
// Basic usage without options
let session = session_exchange_with_options(
&http_client,
protected_resource,
access_token,
&None,
&None,
).await?;§Example with access_token_type
use atproto_oauth_aip::workflow::session_exchange_with_options;
// Specify the token type
let session = session_exchange_with_options(
&http_client,
protected_resource,
access_token,
&Some("oauth_session"),
&None,
).await?;§Example with subject
use atproto_oauth_aip::workflow::session_exchange_with_options;
// Specify both token type and subject
let session = session_exchange_with_options(
&http_client,
protected_resource,
access_token,
&Some("app_password_session"),
&Some(user_did),
).await?;