in pantri/scripts/lib/fb_objectstore.py [0:0]
def get_auth_token(self):
""" Return auth token either from cache or request from object store """
auth_token_cache = os.path.join(self.git_path, '.pantri_auth_token')
# only use cached token if method is 'store' and 'password_file' arg is not
# passed
use_cached_auth_token = (
self.options['method'] == 'store' or not
'password_file' in self.options.keys()
)
if os.path.exists(auth_token_cache) and use_cached_auth_token:
auth_token = self.get_cached_auth_token()
# Validate and return cached auth token.
if auth_token and self.validate_auth_token(auth_token):
return auth_token
else:
self.logger.info('Auth token is invalid. Requesting a new token...')
auth_token = self.request_auth_token()
if use_cached_auth_token:
self.cache_auth_token(auth_token)
return auth_token