def generate_authorization_token(context, private_key):
"""Generate authorization token from the private key."""
expiry = datetime.datetime.utcnow() + datetime.timedelta(days=90)
userid = "testuser"
path_to_private_key = 'data/{private_key}'.format(private_key=private_key)
# initial value
context.token = None
with open(path_to_private_key) as fin:
private_key = fin.read()
payload = {
'exp': expiry,
'iat': datetime.datetime.utcnow(),
'sub': userid
}
token = jwt.encode(payload, key=private_key, algorithm='RS256')
decoded = token.decode('utf-8')
# print(decoded)
context.token = decoded
authorization.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录