client_credentials_token

Function client_credentials_token 

Source
pub async fn client_credentials_token(
    http_client: &Client,
    aip_hostname: &str,
    aip_client_id: &str,
    aip_client_secret: &str,
) -> Result<TokenResponse>
Expand description

Obtains an access token using OAuth client credentials grant.

This function implements the OAuth 2.0 client credentials flow for obtaining service-to-service access tokens. This is typically used when a service needs to authenticate itself rather than acting on behalf of a user.

§Arguments

  • http_client - The HTTP client to use for making requests
  • aip_hostname - The hostname of the AT Protocol Identity Provider (AIP)
  • aip_client_id - The client ID for authenticating with the AIP
  • aip_client_secret - The client secret for authenticating with the AIP

§Returns

Returns a TokenResponse containing the access token and metadata, or an error if the token request fails.

§Example

use atproto_oauth_aip::workflow::client_credentials_token;
use atproto_oauth::workflow::TokenResponse;

let token = client_credentials_token(
    &http_client,
    aip_hostname,
    client_id,
    client_secret,
).await?;

println!("Access token: {}", token.access_token);
println!("Token type: {}", token.token_type);
println!("Expires in: {} seconds", token.expires_in);