问题描述
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.
我是 FastAPI 的新手,因为我在我的项目中实现了 JWT 令牌,API 正常工作,但每次我启动服务器时,它都会显示此警告。
我从 jose 和 CryptContext 从 passlib.context 导入了 jwt python 3.9版
我真的很想知道这背后的原因是什么!
解决方法
弃用警告是由 python-jose
库如何从字节加载整数值引起的。这与 fastapi 无关,而是您正在使用的库中的问题。不过,该问题已在五天前 (2021-04-29) 的 python-jose
中修复,并将在下一个版本中出现。
您可以在 Github 上see the change in the commit。目前您可以忽略该警告,但是一旦 python-jose
的升级版本发布,您应该升级到新版本。