Package: django-ninja-jwt
Ninja JWTAbstractNinja JWT is JSON Web Token plugin for Django-Ninja. The library is a fork ofSimple JWTby Jazzband, a popular  JWT plugin forDjango REST Framework.NoticeThis library does not fix any issues from the source SIMPLE JWT.
It only added support for Django-Ninja and removes DRF dependencies. And time after time, subsequent updates from SIMPLE JWT will reflect here.For full documentation,visit.RequirementsPython >= 3.6Django >= 2.1Django-Ninja >= 0.16.1Django-Ninja-Extra >= 0.14.2ExampleCheckout this sample project:https://github.com/eadwinCode/bookstoreapiInstallationNinja JWT can be installed with pip:pip install django-ninja-jwtAlso, you need to registerNinjaJWTDefaultControllercontroller to your Django-Ninja api.fromninja_jwt.controllerimportNinjaJWTDefaultControllerfromninja_extraimportNinjaExtraAPIapi=NinjaExtraAPI()api.register_controllers(NinjaJWTDefaultController)TheNinjaJWTDefaultControllercomes with three routesobtain_token,refresh_tokenandverify_token.
It is a combination of two subclassesTokenVerificationControllerandTokenObtainPairController.
If you wish to customize these routes, you can inherit from these controllers and change its implementationfromninja_extraimportapi_controllerfromninja_jwt.controllerimportTokenObtainPairController@api_controller('token',tags=['Auth'])classMyCustomController(TokenObtainPairController):"""obtain_token and refresh_token only"...api.register_controllers(MyCustomController)If you wish to use localizations/translations, simply addninja_jwttoINSTALLED_APPS.INSTALLED_APPS=[...'ninja_jwt',...]Using Ninja RouterAlso, if you are not interested in following NinjaExtra methodology, check out this doc on how to useNinja-JWTwithDjango-NinjahereUsageTo verify that Ninja JWT is working, you can use curl to issue a couple
of test requests:curl \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"username": "davidattenborough", "password": "boatymcboatface"}' \
  http://localhost:8000/api/token/pair

...
{
  "access":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiY29sZF9zdHVmZiI6IuKYgyIsImV4cCI6MTIzNDU2LCJqdGkiOiJmZDJmOWQ1ZTFhN2M0MmU4OTQ5MzVlMzYyYmNhOGJjYSJ9.NHlztMGER7UADHZJlxNG0WSi22a2KaYSfd1S-AuT7lU",
  "refresh":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImNvbGRfc3R1ZmYiOiLimIMiLCJleHAiOjIzNDU2NywianRpIjoiZGUxMmY0ZTY3MDY4NDI3ODg5ZjE1YWMyNzcwZGEwNTEifQ.aEoAYkSJjoWH1boshQAaTkf8G3yn0kapko6HFRt7Rh4"
}You can use the returned access token to prove authentication for a
protected view:curl \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiY29sZF9zdHVmZiI6IuKYgyIsImV4cCI6MTIzNDU2LCJqdGkiOiJmZDJmOWQ1ZTFhN2M0MmU4OTQ5MzVlMzYyYmNhOGJjYSJ9.NHlztMGER7UADHZJlxNG0WSi22a2KaYSfd1S-AuT7lU" \
  http://localhost:8000/api/some-protected-view/When this short-lived access token expires, you can use the longer-lived
refresh token to obtain another access token:curl \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"refresh":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImNvbGRfc3R1ZmYiOiLimIMiLCJleHAiOjIzNDU2NywianRpIjoiZGUxMmY0ZTY3MDY4NDI3ODg5ZjE1YWMyNzcwZGEwNTEifQ.aEoAYkSJjoWH1boshQAaTkf8G3yn0kapko6HFRt7Rh4"}' \
  http://localhost:8000/api/token/refresh/

...
{"access":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiY29sZF9zdHVmZiI6IuKYgyIsImV4cCI6MTIzNTY3LCJqdGkiOiJjNzE4ZTVkNjgzZWQ0NTQyYTU0NWJkM2VmMGI0ZGQ0ZSJ9.ekxRxgb9OKmHkfy-zs1Ro_xs1eMLXiR17dIDBVxeT-w"}