TokenSource

Trait TokenSource 

Source
pub trait TokenSource:
    Send
    + Sync
    + 'static {
    // Required method
    fn get_token<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<String, Box<dyn Error + Sync + Send>>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn format_header(&self, token: String) -> String { ... }
}
Expand description

A source for authentication tokens.

Required Methods§

Source

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

Gets a token, possibly refreshing it.

Provided Methods§

Source

fn format_header(&self, token: String) -> String

Formats the token for use in an Authorization header.

The default implementation formats the token as a Bearer token. Override this method if a different format is required.

Implementations on Foreign Types§

Source§

impl TokenSource for String

Source§

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

Implementors§