Registry / security / djangorestframework-simplejwt

djangorestframework-simplejwt

JSON →
library5.5.1pypypi✓ verified 26d ago

A JSON Web Token authentication plugin for the Django REST Framework. It provides a robust and simple way to add JWT-based authentication to Django REST Framework APIs. The current version is 5.3.1, released on 2024-08-28. It is actively maintained with regular releases.

pip install djangorestframework-simplejwt
INSTALL
IMPORT
SIG · DJANGORESTFRAMEWOR
D
djangorestframework-simplejwt
securitypythonv5.5.1
Install
3.8s avg
Import
Disk
71MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 71.6MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.8s · import 0.000s · 72MB
71MB installed
● package 71MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

JWTAuthentication
from rest_framework_simplejwt.authentication import JWTAuthentication
from rest_framework_simplejwt.authentication import JWTAuthentication
TokenObtainPairView
from rest_framework_simplejwt.views import TokenObtainPairView
TokenRefreshView
from rest_framework_simplejwt.views import TokenRefreshView

Add JWT token obtain and refresh endpoints to your Django URL configuration.

from django.urls import path from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView urlpatterns = [ path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), ]
Debug
Known issues
breakingIn version 5.0.0, the default token lifetime changed from 5 minutes to 5 minutes (no change), but the 'AUTH_TOKEN_CLASSES' setting was renamed to 'TOKEN_OBTAIN_SERIALIZER'. Check your settings.
fix
Update your settings to use the new key 'TOKEN_OBTAIN_SERIALIZER' instead of 'AUTH_TOKEN_CLASSES'.
affects: >=5.0.0
deprecatedThe 'JWT_AUTH' cookie header setting is deprecated in favor of 'AUTH_HEADER_TYPES' and 'AUTH_HEADER_NAME'.
fix
Use 'AUTH_HEADER_TYPES': ('Bearer',) and 'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION' in SimpleJWT settings.
affects: >=5.0.0
gotchaWhen using custom user model with email-based authentication, the default 'TokenObtainPairSerializer' expects 'username' field. You must override the serializer to use email.
fix
Create a custom serializer that sets 'username_field' to 'email' or override 'validate' method.
affects: all
Upgrade
Version history
5.5.1latest on PyPI · released Jul 21, 2025
Audit
Dependencies
djangorequiredRequired: Django framework.
djangorestframeworkrequiredRequired: Django REST Framework.
PyJWToptionalRequired: JWT encoding/decoding library.
cryptographyoptionalOptional: Required for RS256/RS512 algorithms.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
djangorestframework-simplejwt — pip install djangorestframework-simplejwt · libregistry