code: private HeaderCacheElement updateToken() {
      HeaderCacheElement newToken;
      try {
        LOG.info("Refreshing the OAuth token");
        newToken = new HeaderCacheElement(credentials.refreshAccessToken());
      } catch (Exception e) {
        LOG.warn("Got an unexpected exception while trying to refresh google credentials.", e);
        newToken = new HeaderCacheElement(
            Status.UNAUTHENTICATED
                .withDescription("Unexpected error trying to authenticate")
                .withCause(e)
        );
      }
      synchronized (lock) {
        // Update the token only if the new token is good or the old token is bad
        if (newToken.isValid() || !headerCache.isValid()) {
          headerCache = newToken;
        } else {
          LOG.warn("Failed to refresh the access token. Falling back to existing token. "
              + "New token state: {}, status: {}", newToken.getCacheState(), newToken.getToken().status);
        }
        futureToken = null;
  
        return headerCache;
      }
    }
docs: Create a new token via {@link OAuth2Credentials#refreshAccessToken()}, and then update the cache.
  @return the new token