pub struct AuthManager { /* private fields */ }Expand description
Authentication manager for HTTP client
Implementations§
Source§impl AuthManager
impl AuthManager
Sourcepub fn new(client: Client, config: HttpConfig) -> Self
pub fn new(client: Client, config: HttpConfig) -> Self
Create a new authentication manager
Sourcepub async fn authenticate_oauth2(&mut self) -> Result<AuthToken, HttpError>
pub async fn authenticate_oauth2(&mut self) -> Result<AuthToken, HttpError>
Authenticate using OAuth2 client credentials
Sourcepub fn generate_api_key_signature(
&self,
api_secret: &str,
timestamp: u64,
nonce: &str,
method: &str,
uri: &str,
body: &str,
) -> Result<String, HttpError>
pub fn generate_api_key_signature( &self, api_secret: &str, timestamp: u64, nonce: &str, method: &str, uri: &str, body: &str, ) -> Result<String, HttpError>
Generate API key signature for request
Get authorization header value
Sourcepub fn generate_nonce() -> String
pub fn generate_nonce() -> String
Generate nonce for API key authentication
Sourcepub fn get_timestamp() -> u64
pub fn get_timestamp() -> u64
Get current timestamp in milliseconds
Sourcepub fn update_token(&mut self, token: AuthToken)
pub fn update_token(&mut self, token: AuthToken)
Updates the authentication token and its expiration time for the current instance.
This method updates the internal state of the object by setting a new authentication token
and calculating its expiration time based on the current system time and the token’s
expires_in duration.
§Arguments
token- An instance ofAuthTokencontaining the new authentication token and its metadata (e.g., expiration duration).
§Effects
- The
self.tokenfield is set to the providedtoken. - The
self.token_expires_atfield is set to the current system time plus theexpires_induration from the providedtoken.
§Note
Ensure that the provided AuthToken is valid and its expires_in duration is correctly
defined in seconds, as it will determine the computed expiration time.
§Panics
This function does not explicitly panic, but unexpected behavior could occur if the
system time manipulation or Duration calculations fail (e.g., overflow).
Trait Implementations§
Source§impl Clone for AuthManager
impl Clone for AuthManager
Source§fn clone(&self) -> AuthManager
fn clone(&self) -> AuthManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more