Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _h():
"""Create a header to provide library metadata"""
return {"Authorization": "Bearer " + get_api_key(),
"x-jovian-source": "library",
"x-jovian-library-version": __version__,
"x-jovian-command": "add-slack",
"x-jovian-guest": get_guest_key(),
"x-jovian-org": read_org_id()}
def _h():
"""Create authorization header with API key"""
return {"Authorization": "Bearer " + get_api_key(),
"x-jovian-source": "library",
"x-jovian-library-version": __version__,
"x-jovian-guest": get_guest_key(),
"x-jovian-org": read_org_id()}
def _request_wrapper(*args, **kwargs):
for i in range(2):
res = request(*args, **kwargs)
if res.status_code == 401:
log('The current API key is invalid or expired.', error=True)
purge_api_key()
# This will ensure that fresh api token is requested
if 'headers' in kwargs:
kwargs['headers']['Authorization'] = "Bearer " + get_api_key()
else:
return res
return res