概要
djangoでJWTを使おうと思い、djangorestframework-jwtを使ってみました。
https://github.com/jpadilla/django-rest-framework-jwt
以下のサイトなどを参考にすすめてみました。
https://dev-yakuza.posstree.com/django/jwt/
ただし、‘rest_framework_jwt.authentication.JSONWebTokenAuthentication’を記述したところで、以下のエラーが発生しました。
調べたところ、以下の記事が見つかりました。
かわりにdjangorestframework-simplejwtを使え、とのことでした。
https://github.com/jazzband/djangorestframework-simplejwt
以下、こちらの使い方についてメモを残します。
djangorestframework-simplejwt
以下のページを参考にすることで、動作確認を行うことができました。
https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html
Postman
usernameとpasswordを使って、以下にpostします。
http://localhost:8000/api/token/
結果、refreshとaccessが得られます。

このaccessのほうの値を使用して、HeaderにAuthorizationを設定して送ります。Bearer [jwt]の形式で送ることで、apiを利用できました。

まとめ
djangoでJWTを使う際の参考になりましたら幸いです。