我正在使用PyJWT在 Python 中生成和验证 JWT。运行pypy3 v2.4。
只需尝试encode
和decode
GitHub 存储库中的示例类似的 JWT。解码时出现以下错误:
decoded = jwt.decode(encoded, secret, algorithm='HS256')
File "/usr/local/site-packages/jwt/api_jwt.py", line 64, in decode
options, **kwargs)
File "/usr/local/site-packages/jwt/api_jws.py", line 115, in decode
key, algorithms)
File "/usr/local/site-packages/jwt/api_jws.py", line 177, in _verify_signature
if not alg_obj.verify(signing_input, key, signature):
File "/usr/local/site-packages/jwt/algorithms.py", line 138, in verify
return constant_time_compare(sig, self.sign(msg, key))
File "/usr/local/site-packages/jwt/compat.py", line 50, in constant_time_compare
result |= ord(x) ^ ord(y)
TypeError: ord() expected string of length 1, but int found
很明显,错误是从模块代码内部生成的。
知道是什么导致了这个错误吗?
谢谢