Class GoogleCredentialsFactory


  • @Factory
    @Requires(classes=com.google.auth.oauth2.GoogleCredentials.class)
    public class GoogleCredentialsFactory
    extends java.lang.Object
    A factory for creating GoogleCredentials.
    Since:
    1.0
    Author:
    graemerocher, Ray Tsang
    • Constructor Detail

      • GoogleCredentialsFactory

        public GoogleCredentialsFactory​(@Nonnull
                                        GoogleCredentialsConfiguration configuration)
        Default constructor.
        Parameters:
        configuration - The configuration
    • Method Detail

      • defaultGoogleCredentials

        @Requires(missingBeans=com.google.auth.oauth2.GoogleCredentials.class) @Requires(classes=com.google.auth.oauth2.GoogleCredentials.class)
        @Primary
        @Singleton
        protected com.google.auth.oauth2.GoogleCredentials defaultGoogleCredentials()
                                                                             throws java.io.IOException
        Method used to return the default GoogleCredentials and provide it as a bean. It will determine which credential in the following way:
        1. If
          gcp.credentials.location
          is specified, use its location
        2. Otherwise, if
          gcp.credentials.encodedKey
          is specified, decode it and use its content
        3. None of the 2 properties were specified, use Application Default credential resolution. See Google Cloud Java authentication. This will resolve credential in the following order:
          1. The credentials file pointed to by the
            GOOGLE_APPLICATION_CREDENTIALS
            environment variable
          2. Credentials provided by the Google Cloud SDK
            gcloud auth application-default login
            command
          3. Google App Engine built-in credentials when running inside of Google App Engine
          4. Google Cloud Shell built-in credentials when running inside of Google Cloud Shell
          5. Google Compute Engine built-in credentials when running inside of Google Compute Engine or Kubernetes Engine
        Returns:
        The GoogleCredentials
        Throws:
        java.io.IOException - An exception if an error occurs