Function oauth_complete

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

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

This function performs the final step of the OAuth authorization code flow by exchanging the authorization code received from the callback for access and refresh tokens. It handles DPoP proof generation and client assertion creation for secure token exchange.

§Arguments

  • http_client - The HTTP client to use for making requests
  • oauth_client - The OAuth client configuration
  • dpop_key_data - The key data for creating DPoP proofs
  • callback_code - The authorization code received from the callback
  • oauth_request - The original OAuth request state
  • document - The identity document containing PDS endpoints

§Returns

A TokenResponse containing the access token, refresh token, and metadata on success.

§Errors

Returns OAuthClientError if the token exchange fails or response parsing fails.