def generate(authorization_id):
"""
Generate an access token based on an (unexpired) authorization id.
"""
auth = authorizationcode.Authorizationcode.get('id=%s', authorization_id)
consumer_key = uuid.uuid3(uuid.NAMESPACE_DNS, base36encode(auth.id) + '-' + base36encode(auth.app_id))
consumer_secret = sha224("%s%s" % (str(uuid.uuid1()), time.time())).hexdigest()
if auth.expires_at > datetime.utcnow():
access_token = Accesstoken(user_id=auth.user_id, app_id=auth.app_id, consumer_key=str(consumer_key), consumer_secret=str(consumer_secret))
access_token.save()
return access_token
else:
return None
评论列表
文章目录