Enum tame_oauth::gcp::TokenProviderWrapper
source · pub enum TokenProviderWrapper {
EndUser(EndUserCredentials),
Metadata(MetadataServerProvider),
ServiceAccount(ServiceAccountProvider),
}Expand description
Wrapper around the different providers that are supported
Variants§
EndUser(EndUserCredentials)
Metadata(MetadataServerProvider)
ServiceAccount(ServiceAccountProvider)
Implementations§
source§impl TokenProviderWrapper
impl TokenProviderWrapper
sourcepub fn get_default_provider() -> Result<Option<Self>, Error>
pub fn get_default_provider() -> Result<Option<Self>, Error>
Get a TokenProvider following the “Google Default Credentials”
flow, in order:
-
If the
GOOGLE_APPLICATION_CREDENTIALSenvironment variable is set, use that as a path to aServiceAccountInfo. -
Check for a gcloud’s Application Default Credentials for
EndUserCredentials -
If we’re running on GCP, use the local metadata server.
-
Otherwise, return None.
If it appears that a method is being used, but is actually invalid,
eg GOOGLE_APPLICATION_CREDENTIALS is set but the file doesn’t exist or
contains invalid JSON, an error is returned with the details
Trait Implementations§
source§impl TokenProvider for TokenProviderWrapper
impl TokenProvider for TokenProviderWrapper
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>,
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]>,
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).
source§fn get_token<'a, S, I>(&self, scopes: I) -> Result<TokenOrRequest, Error>where
S: AsRef<str> + 'a,
I: IntoIterator<Item = &'a S> + Clone,
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. Read more