当查看DRF 文档时发现DRF内置的token是存储在数据库里,这和我在网上搜索资料时认识的token-based authentication有出入。
from rest_framework.authtoken.models import Token # 有Token这个model
其实网上大多数的token是json web token,是和DRF自带的token不同的。JWT只存储在客户端。
引用DRF文档:
JSON Web Token is a fairly new standard which can be used for token-based authentication. Unlike the built-in TokenAuthentication scheme, JWT Authentication doesn‘t need to use a database to validate a token. A package for JWT authentication is djangorestframework-simplejwt which provides some features as well as a pluggable token blacklist app.
原文:https://www.cnblogs.com/allen2333/p/11337230.html