文章内容
2022/5/30 16:29:56,作 者: 黄兵
itsdangerous.exc.BadTimeSignature: Signature b'pn2lywt7kfsyjnfyhhfunf33bra' does not match
最近在使用 itsdangerous 生成用户验证密钥的时候出现了如下错误:
itsdangerous.exc.BadTimeSignature: Signature b'pn2lywt7kfsyjnfyhhfunf33bra' does not match
出现问题的原因:
是由于基于时间的签名无效,则引发。也就是签名可能被篡改,会出现这个异常。
解决方案:
对出现的异常进行判断,示例代码如下:
from itsdangerous import exc try: query_email.check_confirmation(get_token) except exc.SignatureExpired: action = 'expired' return render_template('subscribe/activate.html', title=get_meta.title, keywords=get_meta.keyword, description=get_meta.description, action=action) except exc.BadTimeSignature: action = 'param_error' return render_template('subscribe/activate.html', title=get_meta.title, keywords=get_meta.keyword, description=get_meta.description, action=action)
参考资料:
黄兵个人博客原创。
转载请注明出处:黄兵个人博客 - itsdangerous.exc.BadTimeSignature: Signature b'pn2lywt7kfsyjnfyhhfunf33bra' does not match
评论列表