Struct gcp_auth::AuthenticationManager
source · pub struct AuthenticationManager { /* private fields */ }
Expand description
Authentication manager is responsible for caching and obtaining credentials for the required scope
Construct the authentication manager with AuthenticationManager::new()
or by creating
a CustomServiceAccount
, then converting it into an AuthenticationManager
using the From
impl.
Implementations§
source§impl AuthenticationManager
impl AuthenticationManager
sourcepub async fn new() -> Result<Self, Error>
pub async fn new() -> Result<Self, Error>
Finds a service account provider to get authentication tokens from
Tries the following approaches, in order:
- Check if the
GOOGLE_APPLICATION_CREDENTIALS
environment variable if set; if so, use a custom service account as the token source. - Look for credentials in
.config/gcloud/application_default_credentials.json
; if found, use these credentials to request refresh tokens. - Send a HTTP request to the internal metadata server to retrieve a token; if it succeeds, use the default service account as the token source.
- Check if the
gcloud
tool is available on thePATH
; if so, use thegcloud auth print-access-token
command as the token source.
sourcepub async fn get_token(&self, scopes: &[&str]) -> Result<Token, Error>
pub async fn get_token(&self, scopes: &[&str]) -> Result<Token, Error>
Requests Bearer token for the provided scope
Token can be used in the request authorization header in format “Bearer {token}”
sourcepub async fn project_id(&self) -> Result<String, Error>
pub async fn project_id(&self) -> Result<String, Error>
Request the project ID for the authenticating account
This is only available for service account-based authentication methods.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AuthenticationManager
impl !RefUnwindSafe for AuthenticationManager
impl Send for AuthenticationManager
impl Sync for AuthenticationManager
impl Unpin for AuthenticationManager
impl !UnwindSafe for AuthenticationManager
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more