oauth_complete

Function oauth_complete 

Source
pub async fn oauth_complete(
    http_client: &Client,
    oauth_client: &OAuthClient,
    token_endpoint: &str,
    callback_code: &str,
    oauth_request: &OAuthRequest,
) -> Result<TokenResponse>
Expand description

Completes the OAuth authorization flow by exchanging the authorization code for tokens.

After the user has authorized the application and been redirected back with an authorization code, this function exchanges that code for access tokens using the token endpoint.

§Arguments

  • http_client - The HTTP client to use for making requests
  • oauth_client - OAuth client configuration with credentials
  • authorization_server - Authorization server metadata
  • callback_code - The authorization code received in the callback
  • oauth_request - The original OAuth request containing the PKCE verifier

§Returns

Returns a TokenResponse containing the access token and other token information, or an error if the token exchange fails.

§Example

use atproto_oauth_aip::workflow::oauth_complete;
let token_response = oauth_complete(
    &http_client,
    &oauth_client,
    token_endpoint,
    "auth_code_from_callback",
    &oauth_request,
).await?;
println!("Access token: {}", token_response.access_token);