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

source

pub async fn new() -> Result<Self, Error>

Finds a service account provider to get authentication tokens from

Tries the following approaches, in order:

  1. Check if the GOOGLE_APPLICATION_CREDENTIALS environment variable if set; if so, use a custom service account as the token source.
  2. Look for credentials in .config/gcloud/application_default_credentials.json; if found, use these credentials to request refresh tokens.
  3. 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.
  4. Check if the gcloud tool is available on the PATH; if so, use the gcloud auth print-access-token command as the token source.
source

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}”

source

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§

source§

impl TryFrom<CustomServiceAccount> for AuthenticationManager

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(service_account: CustomServiceAccount) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more