Class ExternalAccountCredentials.Builder (1.29.1-SNAPSHOT)

publicabstractstaticclass ExternalAccountCredentials.BuilderextendsGoogleCredentials.Builder

Base builder for external account credentials.

Inheritance

java.lang.Object > OAuth2Credentials.Builder > GoogleCredentials.Builder > ExternalAccountCredentials.Builder

Constructors

Builder()

protectedBuilder()

Builder(ExternalAccountCredentials credentials)

protectedBuilder(ExternalAccountCredentialscredentials)
Parameter
Name Description
credentials ExternalAccountCredentials

Fields

audience

protectedStringaudience
Field Value
Type Description
String

clientId

protectedStringclientId
Field Value
Type Description
String

clientSecret

protectedStringclientSecret
Field Value
Type Description
String

credentialSource

protectedExternalAccountCredentials.CredentialSourcecredentialSource
Field Value
Type Description
com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource

environmentProvider

protectedEnvironmentProviderenvironmentProvider
Field Value
Type Description
com.google.auth.oauth2.EnvironmentProvider

metricsHandler

protectedExternalAccountMetricsHandlermetricsHandler
Field Value
Type Description
com.google.auth.oauth2.ExternalAccountMetricsHandler

scopes

protectedCollection<String>scopes
Field Value
Type Description
Collection<String>

serviceAccountImpersonationOptions

protectedExternalAccountCredentials.ServiceAccountImpersonationOptionsserviceAccountImpersonationOptions
Field Value
Type Description
com.google.auth.oauth2.ExternalAccountCredentials.ServiceAccountImpersonationOptions

serviceAccountImpersonationUrl

protectedStringserviceAccountImpersonationUrl
Field Value
Type Description
String

subjectTokenType

protectedStringsubjectTokenType
Field Value
Type Description
String

tokenInfoUrl

protectedStringtokenInfoUrl
Field Value
Type Description
String

tokenUrl

protectedStringtokenUrl
Field Value
Type Description
String

transportFactory

protectedHttpTransportFactorytransportFactory
Field Value
Type Description
HttpTransportFactory

universeDomain

protectedStringuniverseDomain
Field Value
Type Description
String

workforcePoolUserProject

protectedStringworkforcePoolUserProject
Field Value
Type Description
String

Methods

build()

publicabstractExternalAccountCredentialsbuild()
Returns
Type Description
ExternalAccountCredentials
Overrides

setAudience(String audience)

publicExternalAccountCredentials.BuildersetAudience(Stringaudience)

Sets the Security Token Service audience, which is usually the fully specified resource name of the workload/workforce pool provider.

Parameter
Name Description
audience String

the Security Token Service audience to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setClientId(String clientId)

publicExternalAccountCredentials.BuildersetClientId(StringclientId)

Sets the optional client ID of the service account from the console.

Parameter
Name Description
clientId String

the service account client id to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setClientSecret(String clientSecret)

publicExternalAccountCredentials.BuildersetClientSecret(StringclientSecret)

Sets the optional client secret of the service account from the console.

Parameter
Name Description
clientSecret String

the service account client secret to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setCredentialSource(ExternalAccountCredentials.CredentialSource credentialSource)

publicExternalAccountCredentials.BuildersetCredentialSource(ExternalAccountCredentials.CredentialSourcecredentialSource)

Sets the external credential source.

Parameter
Name Description
credentialSource com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource

the CredentialSource to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setHttpTransportFactory(HttpTransportFactory transportFactory)

publicExternalAccountCredentials.BuildersetHttpTransportFactory(HttpTransportFactorytransportFactory)

Sets the HTTP transport factory, creates the transport used to get access tokens.

Parameter
Name Description
transportFactory HttpTransportFactory

the HttpTransportFactory to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setQuotaProjectId(String quotaProjectId)

publicExternalAccountCredentials.BuildersetQuotaProjectId(StringquotaProjectId)

Sets the optional project used for quota and billing purposes.

Parameter
Name Description
quotaProjectId String

the quota and billing project id to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

Overrides

setScopes(Collection<String> scopes)

publicExternalAccountCredentials.BuildersetScopes(Collection<String>scopes)

Sets the optional scopes to request during the authorization grant.

Parameter
Name Description
scopes Collection<String>

the request scopes to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setServiceAccountImpersonationOptions(Map<String,Object> optionsMap)

publicExternalAccountCredentials.BuildersetServiceAccountImpersonationOptions(Map<String,Object>optionsMap)

Sets the optional service account impersonation options.

Parameter
Name Description
optionsMap Map<String,Object>

the service account impersonation options to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setServiceAccountImpersonationUrl(String serviceAccountImpersonationUrl)

publicExternalAccountCredentials.BuildersetServiceAccountImpersonationUrl(StringserviceAccountImpersonationUrl)

Sets the optional URL used for service account impersonation, which is required for some APIs. If this URL is not available, the access token from the Security Token Service is used directly.

Parameter
Name Description
serviceAccountImpersonationUrl String

the service account impersonation url to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setSubjectTokenType(ExternalAccountCredentials.SubjectTokenTypes subjectTokenType)

publicExternalAccountCredentials.BuildersetSubjectTokenType(ExternalAccountCredentials.SubjectTokenTypessubjectTokenType)

Sets the Security Token Service subject token type based on the OAuth 2.0 token exchange spec. Indicates the type of the security token in the credential file.

Parameter
Name Description
subjectTokenType ExternalAccountCredentials.SubjectTokenTypes

the SubjectTokenType to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setSubjectTokenType(String subjectTokenType)

publicExternalAccountCredentials.BuildersetSubjectTokenType(StringsubjectTokenType)

Sets the Security Token Service subject token type based on the OAuth 2.0 token exchange spec. Indicates the type of the security token in the credential file.

Parameter
Name Description
subjectTokenType String

the Security Token Service subject token type to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setTokenInfoUrl(String tokenInfoUrl)

publicExternalAccountCredentials.BuildersetTokenInfoUrl(StringtokenInfoUrl)

Sets the optional endpoint used to retrieve account related information. Required for gCloud session account identification.

Parameter
Name Description
tokenInfoUrl String

the token info url to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setTokenUrl(String tokenUrl)

publicExternalAccountCredentials.BuildersetTokenUrl(StringtokenUrl)

Sets the Security Token Service token exchange endpoint.

Parameter
Name Description
tokenUrl String

the Security Token Service token exchange url to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

setUniverseDomain(String universeDomain)

publicExternalAccountCredentials.BuildersetUniverseDomain(StringuniverseDomain)

Sets the optional universe domain.

Parameter
Name Description
universeDomain String

the universe domain to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

Overrides

setWorkforcePoolUserProject(String workforcePoolUserProject)

publicExternalAccountCredentials.BuildersetWorkforcePoolUserProject(StringworkforcePoolUserProject)

Sets the optional workforce pool user project number when the credential corresponds to a workforce pool and not a workload identity pool. The underlying principal must still have serviceusage.services.use IAM permission to use the project for billing/quota.

Parameter
Name Description
workforcePoolUserProject String

the workforce pool user project number to set

Returns
Type Description
ExternalAccountCredentials.Builder

this Builder object

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月30日 UTC.