Class GoogleCredentialsFactory

java.lang.Object
io.micronaut.gcp.credentials.GoogleCredentialsFactory

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

  • Method Details

    • defaultGoogleCredentials

      @Requires(classes=com.google.auth.oauth2.GoogleCredentials.class) @Requires(property="gcp.credentials.enabled",value="true",defaultValue="true") @Primary @Singleton protected com.google.auth.oauth2.GoogleCredentials defaultGoogleCredentials() throws 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:
      IOException - An exception if an error occurs