pub async fn access_token_with_client_credentials(
    http_service: &HttpService,
    client_credentials: ClientCredentials,
    token_endpoint: &Url,
    scope: Option<Scope>,
    now: DateTime<Utc>,
    rng: &mut impl Rng,
) -> Result<AccessTokenResponse, TokenRequestError>
Expand description

Exchange an authorization code for an access token.

This should be used as the first step for logging in, and to request a token with a new scope.

§Arguments

  • http_service - The service to use for making HTTP requests.

  • client_credentials - The credentials obtained when registering the client.

  • token_endpoint - The URL of the issuer’s Token endpoint.

  • scope - The scope to authorize.

  • now - The current time.

  • rng - A random number generator.

§Errors

Returns an error if the request fails or the response is invalid.