code: public void ensureAuthTicket() {
          synchronized (lockObj) {
              if (appAuthTicket == null || refreshInterval.getRefreshTokenExpiration().isBeforeNow())
                  authenticateApp();
              else if (refreshInterval.getAccessTokenExpiration().isBeforeNow())
                  refreshAppAuthTicket();
          }
      }
docs: Ensure that the auth ticket is valid. If not, then make it so. Will be
  used when not using timers to keep the auth ticket alive (i.e.
  "on demand" mode).
  
  @throws ApiException