accesstoken.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:mltshp 作者: MLTSHP 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号