Django使用Token认证(simplejwt库的配置)

目录

官网文档

https://django-rest-framework-simplejwt.readthedocs.io/en/latest/

安装

bash 复制代码
pip install djangorestframework-simplejwt

项目配置

bash 复制代码
REST_FRAMEWORK = {
    ...
    'DEFAULT_AUTHENTICATION_CLASSES': (
        ...
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    )
    ...
}

拓展配置

bash 复制代码
# JWT扩展配置
import datetime
JWT_AUTH = {
    # 设置生成jwt token的有效时间
    'JWT_EXPIRATION_DELTA': datetime.timedelta(days=7),
}
相关推荐
zhaoyong22211 小时前
MySQL 存储过程中字符集与排序规则不匹配导致查询性能下降的解决方案
jvm·数据库·python
sinat_3834373611 小时前
golang如何从Python转型Go开发_golang从Python转型Go开发攻略
jvm·数据库·python
TeDi TIVE11 小时前
springboot和springframework版本依赖关系
java·spring boot·后端
雨辰AI11 小时前
SpringBoot3 + 人大金仓 V9 微服务监控实战|Prometheus+Grafana+SkyWalking 全链路监控
数据库·后端·微服务·grafana·prometheus·skywalking
rockey62711 小时前
基于AScript的python3脚本语言发布啦!
python·c#·.net·script·python3·eval·expression·function·动态脚本
gqk0111 小时前
Python入门
python
Nicander12 小时前
理解 mybatis 源码:vibe-coding一个mini-mybatis
后端·mybatis
Muyuan199812 小时前
28.Paper RAG Agent 开发记录:修复 LLM Rerank 的解析、Fallback 与可验证性
linux·人工智能·windows·python·django·fastapi
代码小书生12 小时前
statistics,一个统计的 Python 库!
开发语言·python
小呆呆66612 小时前
Codex 穷鬼大救星
前端·人工智能·后端