jwt encode error is It is required that you pass in a value for the "algorithms" argument when calling decode().
这个错误的问题是在我们decode的时候仍然需要加入哈希算法的注明
- encode(payload,key,algorithm) 返回类型:token串,bytes类型
payload:字典类型
key:自定义的加密key,字符串类型
algorithm:加密算法,字符串类型
>>> import jwt
>>> name = jwt.encode({'username':'flandre'},'123456',algorithm='HS256')
>>> name
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImZsYW5kcmUifQ.8tQcHObE2zb0qzUNJejdE0Fn4tOSCPbMVqnm5ZYCUGA'
解决方法只需要将加密时写的算法复制过来即可
>>> jwt.decode(name,'123456',algorithms='HS256')
{'username': 'flandre'}