Skip to main content

TokenSource

Trait TokenSource 

Source
pub trait TokenSource: Send + Sync {
    // Required method
    fn fetch_token<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(String, Duration), TokenCacheError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Object-safe async port for acquiring a fresh (token, ttl) pair.

Implement this for custom token acquisition strategies. The built-in implementation is ClientCredentialsSource.

Required Methods§

Source

fn fetch_token<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(String, Duration), TokenCacheError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch a fresh token. Returns the raw JWT string and its lifetime. The cache subtracts TokenCacheConfig::refresh_skew from the TTL before storing the expiry, so the token is treated as stale slightly before the server considers it expired.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§