TokenRefresher

Trait TokenRefresher 

Source
pub trait TokenRefresher:
    Clone
    + Debug
    + Send {
    type Error;

    // Required methods
    fn validated_access_token<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_access_token<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn refresh_access_token<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<String, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn base_url(&self) -> &str;

    // Provided method
    fn should_trace(&self, url: &UrlPatternMatchInput) -> bool { ... }
}
Expand description

Get and refresh access tokens

Required Associated Types§

Source

type Error

The type to be returned in the event of a error during getting or refreshing an access token

Required Methods§

Source

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

Get and validate the current access token, refreshing it if it doesn’t exist or is invalid.

Source

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

Get the current access token, if any

Source

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

Get a fresh access token

Source

fn base_url(&self) -> &str

Get the base URL for requests

Provided Methods§

Source

fn should_trace(&self, url: &UrlPatternMatchInput) -> bool

Returns whether the given URL should be traced. Following [TracingConfiguration::is_enabled], this defaults to true.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§