Trait tame_oauth::gcp::TokenProvider
source · 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§
sourcefn get_token_with_subject<'a, S, I, T>(
&self,
subject: Option<T>,
scopes: I
) -> Result<TokenOrRequest, Error>
fn get_token_with_subject<'a, S, I, T>( &self, subject: Option<T>, scopes: I ) -> Result<TokenOrRequest, Error>
Like TokenProvider::get_token
, but allows the JWT
“subject”
to be passed in.
Provided Methods§
sourcefn get_token<'a, S, I>(&self, scopes: I) -> Result<TokenOrRequest, Error>
fn get_token<'a, S, I>(&self, scopes: I) -> Result<TokenOrRequest, Error>
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.