* 📝 Update JWT auth documentation to use PyJWT instead of pyhon-jose. PR [#11589](https://github.com/tiangolo/fastapi/pull/11589) by [@estebanx64](https://github.com/estebanx64).
* 📝 Update docs. PR [#11603](https://github.com/tiangolo/fastapi/pull/11603) by [@alejsdev](https://github.com/alejsdev).
* 📝 Update docs. PR [#11603](https://github.com/tiangolo/fastapi/pull/11603) by [@alejsdev](https://github.com/alejsdev).
* ✏️ Fix typo: convert every 're-use' to 'reuse'.. PR [#11598](https://github.com/tiangolo/fastapi/pull/11598) by [@hasansezertasan](https://github.com/hasansezertasan).
* ✏️ Fix typo: convert every 're-use' to 'reuse'.. PR [#11598](https://github.com/tiangolo/fastapi/pull/11598) by [@hasansezertasan](https://github.com/hasansezertasan).
* ✏️ Fix typo in `fastapi/applications.py`. PR [#11593](https://github.com/tiangolo/fastapi/pull/11593) by [@petarmaric](https://github.com/petarmaric).
* ✏️ Fix typo in `fastapi/applications.py`. PR [#11593](https://github.com/tiangolo/fastapi/pull/11593) by [@petarmaric](https://github.com/petarmaric).
@ -26,28 +26,24 @@ After a week, the token will be expired and the user will not be authorized and
If you want to play with JWT tokens and see how they work, check <ahref="https://jwt.io/"class="external-link"target="_blank">https://jwt.io</a>.
If you want to play with JWT tokens and see how they work, check <ahref="https://jwt.io/"class="external-link"target="_blank">https://jwt.io</a>.
## Install `python-jose`
## Install `PyJWT`
We need to install `python-jose` to generate and verify the JWT tokens in Python:
We need to install `PyJWT` to generate and verify the JWT tokens in Python:
<divclass="termy">
<divclass="termy">
```console
```console
$ pip install "python-jose[cryptography]"
$ pip install pyjwt
---> 100%
---> 100%
```
```
</div>
</div>
<ahref="https://github.com/mpdavis/python-jose"class="external-link"target="_blank">Python-jose</a> requires a cryptographic backend as an extra.
!!! info
If you are planning to use digital signature algorithms like RSA or ECDSA, you should install the cryptography library dependency `pyjwt[crypto]`.
Here we are using the recommended one: <ahref="https://cryptography.io/"class="external-link"target="_blank">pyca/cryptography</a>.
You can read more about it in the <ahref="https://pyjwt.readthedocs.io/en/latest/installation.html"class="external-link"target="_blank">PyJWT Installation docs</a>.
!!! tip
This tutorial previously used <ahref="https://pyjwt.readthedocs.io/"class="external-link"target="_blank">PyJWT</a>.
But it was updated to use Python-jose instead as it provides all the features from PyJWT plus some extras that you might need later when building integrations with other tools.
## Password hashing
## Password hashing
@ -111,19 +107,19 @@ And another one to authenticate and return a user.
@ -294,7 +290,7 @@ Create a real JWT access token and return it.
!!! tip
!!! tip
Prefer to use the `Annotated` version if possible.
Prefer to use the `Annotated` version if possible.
```Python hl_lines="115-130"
```Python hl_lines="116-131"
{!> ../../../docs_src/security/tutorial004.py!}
{!> ../../../docs_src/security/tutorial004.py!}
```
```
@ -384,7 +380,7 @@ Many packages that simplify it a lot have to make many compromises with the data
It gives you all the flexibility to choose the ones that fit your project the best.
It gives you all the flexibility to choose the ones that fit your project the best.
And you can use directly many well maintained and widely used packages like `passlib` and `python-jose`, because **FastAPI** doesn't require any complex mechanisms to integrate external packages.
And you can use directly many well maintained and widely used packages like `passlib` and `PyJWT`, because **FastAPI** doesn't require any complex mechanisms to integrate external packages.
But it provides you the tools to simplify the process as much as possible without compromising flexibility, robustness, or security.
But it provides you the tools to simplify the process as much as possible without compromising flexibility, robustness, or security.