昨日に引き続き、Postmanでpost, get の動作確認をしながら、Authenticationの動きを観察。
![](https://www.askdjapy.com/wp-content/uploads/2021/03/test_view.png)
![](https://www.askdjapy.com/wp-content/uploads/2021/03/postman-auth-1024x475.png)
トークンの設定をして、一旦、「python3 manage.py flush」でデータベースのデータを消去。
![](https://www.askdjapy.com/wp-content/uploads/2021/03/authtoken.png)
![](https://www.askdjapy.com/wp-content/uploads/2021/03/token.png)
python3 manage.py migrate でマイグレートしておく。
![](https://www.askdjapy.com/wp-content/uploads/2021/03/flush-1024x177.png)
python3 manage.py createsuperuser で再度admin管理者作成
![](https://www.askdjapy.com/wp-content/uploads/2021/03/admin.png)
Token を作成し、再度 Postman で Send してみると、無時に中身が表示できた
![](https://www.askdjapy.com/wp-content/uploads/2021/03/token2.png)
ユーザにトークンを渡す
(urls.py)from rest_framework.authtoken.views import obtain_auth_token
Django Restframework Authentication 参照
![](https://www.askdjapy.com/wp-content/uploads/2021/03/api-token.png)
メンテナンス終了しているが、比較的簡単に導入できるということなので、django-rest-authで試してみた
![](https://www.askdjapy.com/wp-content/uploads/2021/03/django-rest-auth.png)
api token でも django-rest-auth でも同じトークンが返されていることが確認できる。
API endpointsのマニュアルはこちらパスワード再設定や変更も同じ要領で実装できる