Class DataStoreCredentialRefreshListener

  • All Implemented Interfaces:
    CredentialRefreshListener

    @Beta
    public final class DataStoreCredentialRefreshListener
    extends java.lang.Object
    implements CredentialRefreshListener
    Beta
    Thread-safe OAuth 2.0 credential refresh listener that stores the refresh token response in the credential data store.

    It needs to be added as a refresh listener using Credential.Builder.addRefreshListener(com.google.api.client.auth.oauth2.CredentialRefreshListener). Sample usage:

      static void addDataStoreCredentialRefreshListener(
          Credential.Builder credentialBuilder, String userId, DataStoreFactory dataStoreFactory)
          throws IOException {
        credentialBuilder.addRefreshListener(
            new DataStoreCredentialRefreshListener(userId, dataStoreFactory));
      }
     
    Since:
    1.6
    • Field Detail

      • credentialDataStore

        private final com.google.api.client.util.store.DataStore<StoredCredential> credentialDataStore
        Stored credential data store.
      • userId

        private final java.lang.String userId
        User ID whose credential is to be updated.
    • Constructor Detail

      • DataStoreCredentialRefreshListener

        public DataStoreCredentialRefreshListener​(java.lang.String userId,
                                                  com.google.api.client.util.store.DataStoreFactory dataStoreFactory)
                                           throws java.io.IOException
        Constructor using StoredCredential.getDefaultDataStore(DataStoreFactory) for the stored credential data store.
        Parameters:
        userId - user ID whose credential is to be updated
        dataStoreFactory - data store factory
        Throws:
        java.io.IOException
      • DataStoreCredentialRefreshListener

        public DataStoreCredentialRefreshListener​(java.lang.String userId,
                                                  com.google.api.client.util.store.DataStore<StoredCredential> credentialDataStore)
        Parameters:
        userId - user ID whose credential is to be updated
        credentialDataStore - stored credential data store