pub trait TokenSource: Send + Sync {
// Required methods
fn access_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn force_refresh<'life0, 'life1, 'async_trait>(
&'life0 self,
stale: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
A custom access-token source, for callers that need to own token
acquisition and refresh outside the built-in flows — e.g. an
engine-owned token cache with proactive refresh and per-identity fan-out.
Build an Auth from one with Auth::custom.
Required Methods§
Sourcefn access_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn access_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
A valid access token, refreshing through the implementation’s own cache as needed.
Sourcefn force_refresh<'life0, 'life1, 'async_trait>(
&'life0 self,
stale: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn force_refresh<'life0, 'life1, 'async_trait>(
&'life0 self,
stale: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Re-acquire a token after stale was rejected by a 401, bypassing any
cache. If another caller already refreshed past stale, return the
newer token instead of re-acquiring again — single-flight behavior is
the implementation’s responsibility, mirroring the built-in sources.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".