pub struct Credential {
pub service_account: Option<ServiceAccount>,
pub token: Option<Token>,
}Expand description
Credential represents Google credentials that may contain both service account and token.
IMPORTANT: This is a specially designed structure that can hold both ServiceAccount and Token simultaneously. This design is intentional and critical for Google’s authentication:
- Service account only: Used for signed URL generation and JWT-based authentication
- Token only: Used for Bearer authentication (e.g., from metadata server, OAuth2)
- Both: The RequestSigner is responsible for exchanging service account for tokens when needed, and can use cached tokens when available to avoid unnecessary exchanges
The RequestSigner implementation handles the logic of when to use which credential type and when to perform token exchanges. Providers should return credentials as they receive them without trying to perform exchanges themselves.
Fields§
§service_account: Option<ServiceAccount>Service account information, if available.
token: Option<Token>OAuth2 access token, if available.
Implementations§
Source§impl Credential
impl Credential
Sourcepub fn with_service_account(service_account: ServiceAccount) -> Self
pub fn with_service_account(service_account: ServiceAccount) -> Self
Create a credential with only a service account.
Sourcepub fn with_token(token: Token) -> Self
pub fn with_token(token: Token) -> Self
Create a credential with only a token.
Sourcepub fn has_service_account(&self) -> bool
pub fn has_service_account(&self) -> bool
Check if the credential has a service account.
Sourcepub fn has_valid_token(&self) -> bool
pub fn has_valid_token(&self) -> bool
Check if the credential has a valid token.
Trait Implementations§
Source§impl Clone for Credential
impl Clone for Credential
Source§fn clone(&self) -> Credential
fn clone(&self) -> Credential
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Credential
impl Debug for Credential
Source§impl Default for Credential
impl Default for Credential
Source§fn default() -> Credential
fn default() -> Credential
Returns the “default value” for a type. Read more
Source§impl SigningCredential for Credential
impl SigningCredential for Credential
Auto Trait Implementations§
impl Freeze for Credential
impl RefUnwindSafe for Credential
impl Send for Credential
impl Sync for Credential
impl Unpin for Credential
impl UnwindSafe for Credential
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