Expand description
Workforce Identity Federation user Credentials type.
Workforce Identity Federation lets users from an external identity
provider (IdP), such as Microsoft Entra ID or Okta, access Google Cloud
resources. When such a user signs in using
gcloud auth application-default login --login-config=..., gcloud writes
an external_account_authorized_user credentials file. This file contains
an OAuth 2.0 refresh token issued by the Security Token Service (STS).
This module provides Credentials that use that refresh token to obtain access tokens from STS.
The Google Cloud client libraries for Rust will typically find and use these
credentials automatically if a credentials file exists in the
standard ADC search paths. You might instantiate these credentials
directly using the Builder if you need to:
- Load credentials from a non-standard location or source.
- Override the quota project ID for billing and quota management.
- Override the token URL used to refresh access tokens.
- Customize the retry behavior when fetching access tokens.
§Example: Creating credentials from a JSON object
let authorized_user = serde_json::json!({
"type": "external_account_authorized_user",
"audience": "//iam.googleapis.com/locations/global/workforcePools/POOL_ID/providers/PROVIDER_ID",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET", // LOAD SECURELY!
"refresh_token": "YOUR_REFRESH_TOKEN", // LOAD SECURELY!
"token_url": "https://sts.googleapis.com/v1/oauthtoken",
"token_info_url": "https://sts.googleapis.com/v1/introspect",
// "quota_project_id": "your-billing-project-id", // Optional: Set if needed
});
let credentials: Credentials = Builder::new(authorized_user).build()?;
let headers = credentials.headers(Extensions::new()).await?;
println!("Headers: {headers:?}");Structs§
- Builder
- A builder for constructing
external_account_authorized_userCredentials.