CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead

9.6k Views Asked by At
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.

I am new to FastAPI as I was implementing the JWT token in my project the APIs are working as it should be, but each time I start the server it shows this warning.

I have imported jwt from jose and CryptContext from passlib.context python version 3.9

I really love to know what is the reason behind this!

2

There are 2 best solutions below

0
On

The deprecation warning is caused by how the python-jose library loads the integer values from bytes. This is not related to fastapi, but is an issue in the library you're using. However, the issue was fixed in python-jose five days ago (2021-04-29), and will be present in the next release.

You can see the change in the commit on Github. For now you can ignore the warning, but as soon as an upgraded version of python-jose is released you should upgrade to the new version.

0
On

Try to upgrade cryptography package to the newest available version

python3 -m pip install -U cryptography