pub struct DefaultCredentialProvider { /* private fields */ }Expand description
Default credential provider for Google Cloud Storage (GCS).
Resolution order follows ADC (Application Default Credentials):
- Env var
GOOGLE_APPLICATION_CREDENTIALS - Well-known location (
~/.config/gcloud/application_default_credentials.json) - VM metadata service (GCE / Cloud Functions / App Engine)
Implementations§
Source§impl DefaultCredentialProvider
impl DefaultCredentialProvider
Sourcepub fn builder() -> DefaultCredentialProviderBuilder
pub fn builder() -> DefaultCredentialProviderBuilder
Create a builder to configure the default ADC chain for GCS.
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new DefaultCredentialProvider with the default chain: env ADC -> well-known ADC -> VM metadata
Sourcepub fn with_chain(chain: ProvideCredentialChain<Credential>) -> Self
pub fn with_chain(chain: ProvideCredentialChain<Credential>) -> Self
Create with a custom credential chain.
Sourcepub fn push_front(
self,
provider: impl ProvideCredential<Credential = Credential> + 'static,
) -> Self
pub fn push_front( self, provider: impl ProvideCredential<Credential = Credential> + 'static, ) -> Self
Add a credential provider to the front of the default chain.
Sourcepub fn with_scope(self, scope: impl Into<String>) -> Self
👎Deprecated since 1.0.0: Configure scope via specific providers or GOOGLE_SCOPE env var
pub fn with_scope(self, scope: impl Into<String>) -> Self
Set the OAuth2 scope for ADC providers (deprecated).
This helper configures the scope used by the environment and
well-known ADC providers, as well as the VM metadata provider, by
constructing a new chain with the provided scope. Prefer configuring
scope via specific providers (e.g., VmMetadataCredentialProvider::with_scope)
or using the GOOGLE_SCOPE environment variable.