Check Token Expiration

PHOTO EMBED

Thu Aug 05 2021 06:53:24 GMT+0000 (Coordinated Universal Time)

Saved by @faisal_maqsood #python

  def _use_cached_session(self):
    """ Attempt to set the session id from a memcache entry and return success status """
    if not self.cache:
      return False
    expiration = self.cache.get("KEY", namespace="QUEUE_NAME")
    if expiration and expiration > datetime.datetime.utcnow():
      self.session_id = self.cache.get("KEY", namespace="QUEUE_NAME")
      if self.session_id:
        return True
    return False
content_copyCOPY

Class method to check token is valid or not.