def __getJWT(self):
"""
requests JWT from Data Together API. Requires that the environment variable MORPH_DT_API_KEY is set
"""
try:
api_key = os.environ['MORPH_DT_API_KEY']
except KeyError:
raise KeyError('Data Together API Key not set. Set the environment variable MORPH_DT_API_KEY '
'to your Data Together API Key. For instructions on how to do this in morph.io, see '
'https://morph.io/documentation/secret_values')
h = {'access_token':api_key}
token = requests.post('https://ident.archivers.space/jwt', headers=h).content
pubkey = requests.get('https://ident.archivers.space/publickey').content
try:
jwt.decode(token, pubkey, algorithms=['RS256'])
except jwt.exceptions.DecodeError as E:
logging.error('Could not verify Data Together signature on JWT')
raise
return token
评论列表
文章目录