pub struct Builder { /* private fields */ }Expand description
Creates Credentials instances backed by the Metadata Service.
While the Google Cloud client libraries for Rust default to credentials backed by the metadata service, some applications may need to:
- Customize the metadata service credentials in some way
- Bypass the Application Default Credentials lookup and only use the metadata server credentials
- Use the credentials directly outside the client libraries
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn with_endpoint<S: Into<String>>(self, endpoint: S) -> Self
pub fn with_endpoint<S: Into<String>>(self, endpoint: S) -> Self
Sets the endpoint for this credentials.
A trailing slash is significant, so specify the base URL without a trailing
slash. If not set, the credentials use http://metadata.google.internal.
§Example
let credentials = Builder::default()
.with_endpoint("https://metadata.google.foobar")
.build();Sourcepub fn with_quota_project_id<S: Into<String>>(self, quota_project_id: S) -> Self
pub fn with_quota_project_id<S: Into<String>>(self, quota_project_id: S) -> Self
Set the quota project for this credentials.
In some services, you can use a service account in
one project for authentication and authorization, and charge
the usage to a different project. This may require that the
service account has serviceusage.services.use permissions on the quota project.
Sourcepub fn with_universe_domain<S: Into<String>>(self, universe_domain: S) -> Self
pub fn with_universe_domain<S: Into<String>>(self, universe_domain: S) -> Self
Sets the universe domain for this credentials.
Client libraries use universe_domain to determine
the API endpoints to use for making requests.
If not set, then credentials use ${service}.googleapis.com,
otherwise they use `${service}.${universe_domain}.
Sourcepub fn with_scopes<I, S>(self, scopes: I) -> Self
pub fn with_scopes<I, S>(self, scopes: I) -> Self
Sets the scopes for this credentials.
Metadata server issues tokens based on the requested scopes. If no scopes are specified, the credentials defaults to all scopes configured for the default service account on the instance.
Sourcepub fn build(self) -> Result<Credentials, CredentialsError>
pub fn build(self) -> Result<Credentials, CredentialsError>
Returns a Credentials instance with the configured settings.