CryptographyDeprecationWarning:int_from_bytes 已弃用,请使用 int.from_bytes 代替

Ajm*_*Ali 5 python jwt python-jose fastapi

INFO:Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) 
INFO:Started reloader process [27528] using statreload
C:Python\Python39\lib\site-packages\jose\backends\cryptography_backend.py:18:
CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes 
instead from cryptography.utils import int_from_bytes, int_to_bytes 
INFO: Started server process [8912]
INFO: Waiting for application startup. 
INFO: Application startup complete.
Run Code Online (Sandbox Code Playgroud)

我是 FastAPI 的新手,因为我在项目中实现 JWT 令牌,API 正常工作,但每次启动服务器时都会显示此警告。

我已经从 jose 导入了 jwt,并从 passlib.context python 版本 3.9 导入了 CryptContext

我真的很想知道这背后的原因是什么!

Mat*_*ndh 3

弃用警告是由python-jose库如何从字节加载整数值引起的。这与 fastapi 无关,而是您正在使用的库中的问题。但是,该问题已解决python-jose五天前(2021-04-29)得到修复,并将在下一个版本中出现。

您可以在 Github 上的提交中看到更改。目前您可以忽略该警告,但一旦发布升级版本,python-jose您应该立即升级到新版本。