【djangorestframework_simplejwt】JWT认证模块
转载资料:
资料1:https://blog.csdn.net/kaikai0803/article/details/98766036
资料2:https://blog.csdn.net/weixin_42134789/article/details/109554843
一、安装
pip install djangorestframework_simplejwt
二、//settings.py 设置:
REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema', # 生成drf自动文档
# settings配置全局认证,配置登录
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework_simplejwt.authentication.JWTAuthentication', # djangorestframework_simplejwt JWT认证
'rest_framework.authentication.BasicAuthentication', # Basic认证(账号密码)
'rest_framework.authentication.SessionAuthentication', # Session认证
]
}
# 如果要覆盖Simple JWT的默认设置。
from datetime impo