pub trait TokenProvider: Send + Sync {
// Required method
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;
// Provided method
fn refresh<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Supplies the access token each request goes out with.
Required Methods§
Provided Methods§
Sourcefn refresh<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn refresh<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Asked once when a request is answered with 401. Answer true when the next
access_token will hand out renewed credentials, and the request is sent again.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<P: TokenProvider + ?Sized> TokenProvider for Arc<P>
A provider behind an Arc is a provider, so one can be shared with the client and
kept by the application — to watch its refreshes, say.
impl<P: TokenProvider + ?Sized> TokenProvider for Arc<P>
A provider behind an Arc is a provider, so one can be shared with the client and
kept by the application — to watch its refreshes, say.