pub trait TokenProvider {
    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>,
        T: Into<String>
;
fn parse_token_response<S>(
        &self,
        hash: u64,
        response: Response<S>
    ) -> Result<Token, Error>
    where
        S: AsRef<[u8]>
; fn get_token<'a, S, I>(&self, scopes: I) -> Result<TokenOrRequest, Error>
    where
        S: AsRef<str> + 'a,
        I: IntoIterator<Item = &'a S>
, { ... } }
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

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

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

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.

Implementors