ez-token 0.1.0

CLI tool for generating OAuth2 access tokens via PKCE and Client Credentials for Microsoft Entra ID and Auth0
Documentation
use miette::Result;
use miette::{IntoDiagnostic, WrapErr};
use oauth2::reqwest::{Client, redirect};

/// Creates an HTTP client configured for OAuth2 token requests.
///
/// Redirects are explicitly disabled, as OAuth2 flows manage redirects
/// at the protocol level rather than the HTTP level. Allowing automatic
/// redirects could silently swallow authorization errors or redirect
/// sensitive credentials to unintended endpoints.
///
/// # Errors
///
/// Returns an error if the HTTP client fails to initialize, which may
/// occur if the underlying TLS backend cannot be loaded.
pub fn create_http_client() -> Result<Client> {
    Client::builder()
        .redirect(redirect::Policy::none())
        .build()
        .into_diagnostic()
        .wrap_err("Failed to initialize HTTP client")
}