Send feedback
  
   
 
  
    
      Class ExternalAccountCredentials.Builder (1.29.1-SNAPSHOT)
    
    
       
    
    
      
      Stay organized with collections
     
    
      
      Save and categorize content based on your preferences.
     
    
  
      
     
  
  
   
  
    
  
  
    
    
    
  Version 1.29.1-SNAPSHOTkeyboard_arrow_down  
  
 
    
    
     
    
    
    
    
    
      
  
  
  
    
public   abstract   static   class  ExternalAccountCredentials . Builder   extends   GoogleCredentials . Builder  
   
  Base builder for external account credentials.
 
  
  
  Constructors
   
   
  Builder() 
  
   
  Builder(ExternalAccountCredentials credentials) 
  
    
protected   Builder ( ExternalAccountCredentials   credentials )  
   
  
  Fields
   
  audience 
  
    
protected   String   audience  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        String  
         
       
     
  
  clientId 
  
    
protected   String   clientId  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        String  
         
       
     
  
  clientSecret 
  
    
protected   String   clientSecret  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        String  
         
       
     
  
  credentialSource 
  
    
protected   ExternalAccountCredentials . CredentialSource   credentialSource  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource  
         
       
     
  
  environmentProvider 
  
    
protected   EnvironmentProvider   environmentProvider  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        com.google.auth.oauth2.EnvironmentProvider  
         
       
     
  
  metricsHandler 
  
    
protected   ExternalAccountMetricsHandler   metricsHandler  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        com.google.auth.oauth2.ExternalAccountMetricsHandler  
         
       
     
  
  scopes 
  
    
protected   Collection<String>   scopes  
   
  
  serviceAccountImpersonationOptions 
  
    
protected   ExternalAccountCredentials . ServiceAccountImpersonationOptions   serviceAccountImpersonationOptions  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        com.google.auth.oauth2.ExternalAccountCredentials.ServiceAccountImpersonationOptions  
         
       
     
  
  serviceAccountImpersonationUrl 
  
    
protected   String   serviceAccountImpersonationUrl  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        String  
         
       
     
  
  subjectTokenType 
  
    
protected   String   subjectTokenType  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        String  
         
       
     
  
  tokenInfoUrl 
  
    
protected   String   tokenInfoUrl  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        String  
         
       
     
  
  tokenUrl 
  
    
protected   String   tokenUrl  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        String  
         
       
     
  
  transportFactory 
  
    
protected   HttpTransportFactory   transportFactory  
   
  
  universeDomain 
  
    
protected   String   universeDomain  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        String  
         
       
     
  
  workforcePoolUserProject 
  
    
protected   String   workforcePoolUserProject  
   
  
    
      
        Field Value  
       
      
        Type  
        Description  
       
      
        String  
         
       
     
  
  Methods
   
   
  build() 
  
    
public   abstract   ExternalAccountCredentials   build ()  
   
  
  Overrides 
  
   
  setAudience(String audience) 
  
    
public   ExternalAccountCredentials . Builder   setAudience ( String   audience )  
   
  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
 
       
     
  
  
   
  setClientId(String clientId) 
  
    
public   ExternalAccountCredentials . Builder   setClientId ( String   clientId )  
   
  Sets the optional client ID of the service account from the console.
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        clientId 
        String the service account client id to set
 
       
     
  
  
   
  setClientSecret(String clientSecret) 
  
    
public   ExternalAccountCredentials . Builder   setClientSecret ( String   clientSecret )  
   
  Sets the optional client secret of the service account from the console.
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        clientSecret 
        String the service account client secret to set
 
       
     
  
  
   
  setCredentialSource(ExternalAccountCredentials.CredentialSource credentialSource) 
  
    
public   ExternalAccountCredentials . Builder   setCredentialSource ( ExternalAccountCredentials . CredentialSource   credentialSource )  
   
  Sets the external credential source.
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        credentialSource 
        com.google.auth.oauth2.ExternalAccountCredentials.CredentialSource the CredentialSource to set
 
       
     
  
  
   
  setHttpTransportFactory(HttpTransportFactory transportFactory) 
  
    
public   ExternalAccountCredentials . Builder   setHttpTransportFactory ( HttpTransportFactory   transportFactory )  
   
  Sets the HTTP transport factory, creates the transport used to get access tokens.
 
  
  
   
  setQuotaProjectId(String quotaProjectId) 
  
    
public   ExternalAccountCredentials . Builder   setQuotaProjectId ( String   quotaProjectId )  
   
  Sets the optional project used for quota and billing purposes.
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        quotaProjectId 
        String the quota and billing project id to set
 
       
     
  
  
  Overrides 
  
   
  setScopes(Collection<String> scopes) 
  
    
public   ExternalAccountCredentials . Builder   setScopes ( Collection<String>   scopes )  
   
  Sets the optional scopes to request during the authorization grant.
 
  
  
   
  setServiceAccountImpersonationOptions(Map<String,Object> optionsMap) 
  
    
public   ExternalAccountCredentials . Builder   setServiceAccountImpersonationOptions ( 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
 
       
     
  
  
   
  setServiceAccountImpersonationUrl(String serviceAccountImpersonationUrl) 
  
    
public   ExternalAccountCredentials . Builder   setServiceAccountImpersonationUrl ( String   serviceAccountImpersonationUrl )  
   
  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
 
       
     
  
  
   
  setSubjectTokenType(ExternalAccountCredentials.SubjectTokenTypes subjectTokenType) 
  
    
public   ExternalAccountCredentials . Builder   setSubjectTokenType ( ExternalAccountCredentials . SubjectTokenTypes   subjectTokenType )  
   
  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.
 
  
  
   
  setSubjectTokenType(String subjectTokenType) 
  
    
public   ExternalAccountCredentials . Builder   setSubjectTokenType ( String   subjectTokenType )  
   
  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
 
       
     
  
  
   
  setTokenInfoUrl(String tokenInfoUrl) 
  
    
public   ExternalAccountCredentials . Builder   setTokenInfoUrl ( String   tokenInfoUrl )  
   
  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
 
       
     
  
  
   
  setTokenUrl(String tokenUrl) 
  
    
public   ExternalAccountCredentials . Builder   setTokenUrl ( String   tokenUrl )  
   
  Sets the Security Token Service token exchange endpoint.
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        tokenUrl 
        String the Security Token Service token exchange url to set
 
       
     
  
  
   
  setUniverseDomain(String universeDomain) 
  
    
public   ExternalAccountCredentials . Builder   setUniverseDomain ( String   universeDomain )  
   
  Sets the optional universe domain.
 
  
    
      
        Parameter  
       
      
        Name  
        Description  
       
      
        universeDomain 
        String the universe domain to set
 
       
     
  
  
  Overrides 
  
   
  setWorkforcePoolUserProject(String workforcePoolUserProject) 
  
    
public   ExternalAccountCredentials . Builder   setWorkforcePoolUserProject ( String   workforcePoolUserProject )  
   
  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
 
       
     
  
  
 
     
    
  
  
  
     
  
 
  
    
    
      
    
     
  
       
         
  
  
    
    Send feedback
  
   
 
       
    
    
  
  
 
  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.
 
 
  
  
    
    
    
      
  
  
    Need to tell us more?
  
   
 
     
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-30 UTC."],[],[]]