Ensures all tokens are still valid. If expired, attempts to refresh.
        Deletes those which fail to refresh or cannot be refreshed.
        :return: All tokens which are still valid.
        :rtype: :class:`esi.managers.TokenQueryset`
436238
def require_valid(self):
        
        expired = self.get_expired()
        valid = self.exclude(pk__in=expired)
        valid_expired = expired.bulk_refresh()
        return valid_expired | valid
365068
def revoke_tokens(self):
        

        self.is_active = False
        self.save()

        for access_token in self.access_tokens.all():
            access_token.revoke()
798683
def refreshQueryRecords(self):
        
        if self._recordSet is not None:
            records = RecordSet(self._recordSet)
        elif self.tableType():
            records = self.tableType().select()
        else:
            return
        
        records.setDatabase(self.database())
        
        # replace the base query with this widget
        if self.queryAction() == XOrbTreeWidget.QueryAction.Replace:
            if self.query():
                records.setQuery(self.query())
            else:
                records.setQuery(None)
        
        # join together the query for this widget
        elif self.queryAction() == XOrbTreeWidget.QueryAction.Join:
            if records.query():
                records.setQuery(self.query() & self.query())
            elif self.query():
                records.setQuery(self.query())
            else:
                records.setQuery(None)
        
        self._recordSet = records
        
        if not self.signalsBlocked():
            self.queryChanged.emit()
            self.recordsChanged.emit()
544798
def validate_exp(max_clock_skew = 0)
      max_clock_skew ||= 0

      exp = time_claim("exp")
      if exp && exp <= (Time.now - max_clock_skew)
        raise Sandal::ExpiredTokenError, "The token has expired." 
      end
    end
1145197
def token(self):
        
        if self._token is None or \
           datetime.datetime.now() >= self._token_expires_on:
            if self._referer_url is None:
                result = self._generateForTokenSecurity(username=self._username,
                                                    password=self._password,
                                                    tokenUrl=self._token_url)
            else:
                result = self._generateForTokenSecurity(username=self._username,
                                                        password=self._password,
                                                        tokenUrl=self._token_url,
                                                        client="referer")
            if 'error' in result:
                self._valid = False
                self._message = result
            else:
                self._valid = True
                self._message = "Token Generated"
        return self._token
1066081
def is_authenticated(self):
        
        token = self.con.token_backend.token
        if not token:
            token = self.con.token_backend.get_token()

        return token is not None and not token.is_expired
268488
def find_all_cached_entries(query)
      logger.verbose("Searching cache for tokens by keys: #{query.keys}.")
      @token_cache.find do |entry|
        query.map do |k, v|
          (entry.respond_to? k.to_sym) && (v == entry.send(k.to_sym))
        end.reduce(:&)
      end
    end
355138
def authenticated(func):
    
    @wraps(func)
    def wrapper(*args, **kwargs):
        self = args[0]
        if self.refresh_token is not None and \
           self.token_expiration_time <= dt.datetime.utcnow():
            self.re_authenticate()
        return func(*args, **kwargs)
    return wrapper
94427
def _check_token(self):
        
        need_token = (self._token_info is None or
                      self.auth_handler.is_token_expired(self._token_info))
        if need_token:
            new_token = \
                self.auth_handler.refresh_access_token(
                    self._token_info['refresh_token'])
            # skip when refresh failed
            if new_token is None:
                return

            self._token_info = new_token
            self._auth_header = {"content-type": "application/json",
                                 "Authorization": "Bearer {}".format(
                                     self._token_info.get('access_token'))}
931008
def delete_token(self):
        
        if self.token_path.exists():
            self.token_path.unlink()
            return True
        return False
1179139
def get_expired(self):
        
        max_age = timezone.now() - timedelta(seconds=app_settings.ESI_TOKEN_VALID_DURATION)
        return self.filter(created__lte=max_age)
930836
def auth_expired(self):
        
        if self._auth and self._expires:
            now_with_skew = time.time() + AUTH_TOKEN_CLOCK_SKEW_MAX
            return now_with_skew > self._expires
        return True
457017
def valid_for_deletion?
      return false if(id.nil? || sync_token.nil?)
      id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
    end
107563
def tokens(self):
        
        if self._tokens is None:
            self._tokens = TokenList(self._version, account_sid=self._solution['sid'], )
        return self._tokens
946497
def hasExpired(self):
        
        return (datetime.datetime.utcnow() - self.lastUpdateTime).total_seconds() > self.maxAgeSeconds
1268032
def token(self):
        
        if self._token is None or \
           datetime.datetime.now() >= self._token_expires_on:
            result = self._getTokenArcMap()
            if 'error' in result:
                self._valid = False
                self._message = result
            else:
                self._valid = True
                self._message = "Token Generated"
        return self._token
125008
def _check_app_is_valid(client):
    
    try:
        if 'refresh_token' in client.creds:
            client.exchange_refresh_token()
        else:
            existing.get_token_info()
        return True
    except TokenEndpointError as e:
        return False