Trait tame_oauth::gcp::TokenProvider
source · [−]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
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 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>,
Like TokenProvider::get_token
, but allows the JWT
“subject”
to be passed in.
Provided methods
fn get_token<'a, S, I>(&self, scopes: I) -> Result<TokenOrRequest, Error> where
S: AsRef<str> + 'a,
I: IntoIterator<Item = &'a S>,
fn get_token<'a, S, I>(&self, scopes: I) -> Result<TokenOrRequest, Error> where
S: AsRef<str> + 'a,
I: IntoIterator<Item = &'a S>,
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.