RefreshingOAuth2CredentialsInterceptor (Cloud Bigtable HBase Client for Java 0.9.3-SNAPSHOT API)

Class RefreshingOAuth2CredentialsInterceptor

  • java.lang.Object
  • All Implemented Interfaces:

    public class RefreshingOAuth2CredentialsInterceptor
    extends Object
    implements HeaderInterceptor
    Client interceptor that authenticates all calls by binding header data provided by a credential. Typically this will populate the Authorization header but other headers may also be filled out.

    Uses the new and simplified Google auth library:

    TODO: COPIED FROM io.grpc.auth.ClientAuthInterceptor. The logic added here for initialization and locking could be moved back to gRPC. This implementation takes advantage of the fact that all of the Bigtable endpoints are OAuth2 based. It uses the OAuth AccessToken to get the token value and next refresh time. The refresh is scheduled asynchronously.

    $Id: $Id
    • Constructor Detail

      • RefreshingOAuth2CredentialsInterceptor

        public RefreshingOAuth2CredentialsInterceptor(ExecutorService scheduler,
                                                      RetryOptions retryOptions)

        Constructor for RefreshingOAuth2CredentialsInterceptor.

        scheduler - a ExecutorService object.
        credentials - a OAuth2Credentials object.
        retryOptions - a RetryOptions object.
    • Method Detail

      • updateHeaders

        public void updateHeaders(io.grpc.Metadata headers)
                           throws Exception
        Modify the headers before an RPC call is made.
        Specified by:
        updateHeaders in interface HeaderInterceptor
        headers - a Metadata object.
        Exception - if any.
      • asyncRefresh

        public void asyncRefresh()


      • refreshCredentialsWithRetry

        protected refreshCredentialsWithRetry()

        Calls OAuth2Credentials.refreshAccessToken(). In case of an IOException, retry the call as per the BackOff policy defined by RetryOptions.createBackoff().

        This method retries until one of the following conditions occurs:

        1. An OAuth request was completed. If the value is null, return an exception.
        2. A non-IOException Exception is thrown - return an error status
        3. All retries have been exhausted, i.e. when the Backoff.nextBackOffMillis() returns BackOff.STOP
        4. An interrupt occurs.
        HeaderCacheElement containing either a valid AccessToken or an exception.
      • getRetryState

        protected getRetryState( backoff)
                                                                                                             throws IOException
        Sleep and/or determine if the backoff has timed out.
        backoff - a BackOff object.
        RetryState indicating the current state of the retry logic.
        IOException - in some cases from BackOff.nextBackOffMillis()

Send feedback about...

Cloud Bigtable Documentation