def _castAuthResponseToEntity(self, dict): res = OAuthToken() res.access_token = dict['access_token'] res.token_type = dict['token_type'] res.expires_in = dict['expires_in'] res.valid = True if (self._root.Config.DebugMode): logging.getLogger(__name__).debug('New token created: {0} '.format(res.access_token)) return res
def Get(self, envKey): """Gets the currently stored objects as dictionary. return stored Token dictionary or null. """ DefaultStorageStrategy.cache_path = os.path.join( Configuration.TempPath, "cached-data." + envKey + ".py") if not os.path.exists(DefaultStorageStrategy.cache_path): return None fp = open(DefaultStorageStrategy.cache_path, 'rb') lock = lockfile.mkdirlockfile.MkdirLockFile( DefaultStorageStrategy.cache_path) while not lock.i_am_locking(): try: lock.acquire(timeout=2) except LockTimeout: lock.break_lock() lock.acquire() serializedObj = fp.read().decode('UTF-8') try: cached = json.loads(serializedObj[1:]) except: cached = None fp.close() lock.release() return OAuthToken(cached)
def _castAuthResponseToEntity(self, dict): res = OAuthToken() res.access_token = dict['access_token'] res.token_type = dict['token_type'] res.expires_in = dict['expires_in'] res.valid = True if (self._root.Config.DebugMode): logging.getLogger(__name__).debug('New token created: {0} '.format( res.access_token)) return res
def Get(self, envKey): """Gets the currently stored objects as dictionary. return stored Token dictionary or null. """ DefaultStorageStrategy.cache_path = os.path.join( Configuration.TempPath, "cached-data." + envKey + ".py") if not os.path.exists(DefaultStorageStrategy.cache_path): return None lock = fasteners.ReaderWriterLock() with lock.read_lock(): fp = open(DefaultStorageStrategy.cache_path, 'rb') serializedObj = fp.read().decode('UTF-8') try: cached = json.loads(serializedObj[1:]) except: cached = None fp.close() return OAuthToken(cached)