pub trait TokenProvider {
    // Required methods
    fn get_token_with_subject<'a, S, I, T>(
        &self,
        subject: Option<T>,
        scopes: I
    ) -> Result<TokenOrRequest, Error>
       where S: AsRef<str> + 'a,
             I: IntoIterator<Item = &'a S> + Clone,
             T: Into<String>;
    fn parse_token_response<S>(
        &self,
        hash: u64,
        response: Response<S>
    ) -> Result<Token, Error>
       where S: AsRef<[u8]>;

    // Provided method
    fn get_token<'a, S, I>(&self, scopes: I) -> Result<TokenOrRequest, Error>
       where S: AsRef<str> + 'a,
             I: IntoIterator<Item = &'a S> + Clone { ... }
}
Expand description

A TokenProvider has a single method to implement get_token_with_subject. Implementations are free to perform caching or always return a Request in the TokenOrRequest.

Required Methods§

source

fn get_token_with_subject<'a, S, I, T>( &self, subject: Option<T>, scopes: I ) -> Result<TokenOrRequest, Error>
where S: AsRef<str> + 'a, I: IntoIterator<Item = &'a S> + Clone, T: Into<String>,

Like TokenProvider::get_token, but allows the JWT “subject” to be passed in.

source

fn parse_token_response<S>( &self, hash: u64, response: Response<S> ) -> Result<Token, Error>
where S: AsRef<[u8]>,

Once a response has been received for a token request, call this method to deserialize the token (and potentially store it in a local cache for reuse until it expires).

Provided Methods§

source

fn get_token<'a, S, I>(&self, scopes: I) -> Result<TokenOrRequest, Error>
where S: AsRef<str> + 'a, I: IntoIterator<Item = &'a S> + Clone,

Attempts to retrieve a token that can be used in an API request, if we haven’t already retrieved a token for the specified scopes, or the token has expired, an HTTP request is returned that can be used to retrieve a token.

Note that the scopes are not sorted or in any other way manipulated, so any modifications to them will require a new token to be requested.

Object Safety§

This trait is not object safe.

Implementors§