Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
         
       
     
  
  
  
  
  
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  
GoogleApiClientUtil
  public
  
  
  
  class
  GoogleApiClientUtil
  
  
  
  
    extends GoogleApiClientUtilBase
  
  
  
  
  
  
  
    
  Utils for create Google API client.
Summary
| Public methods | 
|---|
  
  
  
    | 
        
        
        static
        
        
        Credentials | 
      createCredential( scopes, File primaryKeyFile, String hostOptionKeyFileName, File... backupKeyFiles)
      Try to create credential with different key files or from local host.
        
    
 | 
  
  
  
  
    | 
        
        
        static
        
        
        Credentials | 
      createCredential( scopes, boolean useCredentialFactory, File primaryKeyFile, String hostOptionKeyFileName, File... backupKeyFiles)
      Try to create credential with different key files or from local host.
        
    
 | 
  
Public constructors
    GoogleApiClientUtil
    
public GoogleApiClientUtil ()
    
    
    
  
 
Public methods
    createCredential
    
public static Credentials createCredential ( scopes, 
                File primaryKeyFile, 
                String hostOptionKeyFileName, 
                File... backupKeyFiles)
    
    
    
  Try to create credential with different key files or from local host.
 
1. If primaryKeyFile is set, try to use it to create credential. 2. Try to get
 corresponding key files from HostOptions. 3. Try to use backup key files. 4. Use
 local default credential.
    
    | Parameters | 
|---|
      
        | scopes | : scopes for the credential. | 
      
        | primaryKeyFile | File: the primary json key file; it can be null. | 
      
        | hostOptionKeyFileName | String:HostOptions'service-account-json-key-file option's key;
     it can be null. | 
      
        | backupKeyFiles | File: backup key files. | 
    
    
      
      | Throws | 
|---|
        
          |  | IOException | 
        
          |  | GeneralSecurityException | 
      
  
 
    createCredential
    
public static Credentials createCredential ( scopes, 
                boolean useCredentialFactory, 
                File primaryKeyFile, 
                String hostOptionKeyFileName, 
                File... backupKeyFiles)
    
    
    
  Try to create credential with different key files or from local host.
 
1. Use ICredentialFactory if useCredentialFactory is true and a ICredentialFactory is configured. If primaryKeyFile is set, try to use it to create
 credential. 2. Try to get corresponding key files from HostOptions. 3. Try to use
 backup key files. 4. Use local default credential.
    
    | Parameters | 
|---|
      
        | scopes | : scopes for the credential. | 
      
        | useCredentialFactory | boolean: use credential factory if it's configured. | 
      
        | primaryKeyFile | File: the primary json key file; it can be null. | 
      
        | hostOptionKeyFileName | String:HostOptions'service-account-json-key-file option's key;
     it can be null. | 
      
        | backupKeyFiles | File: backup key files. | 
    
    
      
      | Throws | 
|---|
        
          |  | IOException | 
        
          |  | GeneralSecurityException | 
      
  
 
 
 
  
  
 
  
    
    
      
    
    
  
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2024-08-13 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-13 UTC."],[],[]]