Class CredentialModule

  • @Module
    public abstract class CredentialModule
    extends java.lang.Object
    Dagger module that provides all GoogleCredentials used in the application.
    • Constructor Detail

      • CredentialModule

        public CredentialModule()
    • Method Detail

      • provideDefaultCredential

        public static GoogleCredentialsBundle provideDefaultCredential​(@Config("defaultCredentialOauthScopes")
                                                             <java.lang.String> requiredScopes)
        Provides the default GoogleCredentialsBundle from the Google Cloud runtime.

        The credential returned depends on the runtime environment:

        • On AppEngine, returns the service account credential for
        • On Compute Engine, returns the service account credential for
        • On end user host, this returns the credential downloaded by gcloud. Please refer to Cloud SDK documentation for details.
      • provideGSuiteDriveCredential

        public static provideGSuiteDriveCredential​(@Config("defaultCredentialOauthScopes")
                                                                                                       <java.lang.String> requiredScopes)
        Provides the default GoogleCredential from the Google Cloud runtime for G Suite Drive API. TODO(b/138195359): Deprecate this credential once we figure out how to use GoogleCredentials for G Suite Drive API.
      • provideJsonCredential

        public static GoogleCredentialsBundle provideJsonCredential​(@Config("defaultCredentialOauthScopes")
                                                          <java.lang.String> requiredScopes,
                                                                    java.lang.String jsonCredential)
        Provides a GoogleCredentialsBundle from the service account's JSON key file.

        On App Engine, a thread created using Java's built-in API needs this credential when it calls App Engine API. The Google Sheets API also needs this credential.

      • provideDelegatedCredential

        public static GoogleCredentialsBundle provideDelegatedCredential​(@Config("delegatedCredentialOauthScopes")
                                                               <java.lang.String> requiredScopes,
                                                                         GoogleCredentialsBundle credentialsBundle,
                                                                         java.lang.String gSuiteAdminAccountEmailAddress)
        Provides a GoogleCredentialsBundle with delegated admin access for a G Suite domain.

        The G Suite domain must grant delegated admin access to the registry service account with all scopes in requiredScopes, including ones not related to G Suite.