Skip to main content

Additions for Django Rest Framework Simple JWT

Project description

DRF SimpleJWT additions

Additional features for django-rest-framework-simplejwt.


Features

  • Full user info in TokenObtainPairSerializer
  • Full user info in TokenObtainPairView

Installation

pip install drf-simplejwt-additions

Usage

Full user info in TokenObtainPairSerializer

In settings.py:

INSTALLED_APPS = [
    ...
    'drf_simplejwt_additions',
    ...
]
  
...
  
SIMPLE_JWT = {
    ...
    "TOKEN_OBTAIN_SERIALIZER": "drf_simplejwt_additions.serializers.TokenObtainPairWithFullUserSerializer",
    ...
}

From now on, the response of the TokenObtainPairView will contain the full user info.
Serializer get all fields from the user model, except password and fields that start with _.
Then theses fields are added to the response in the user field.


Full user info in TokenObtainPairView

In urls.py:

from drf_simplejwt_additions.views import TokenObtainPairWithFullUserView

urlpatterns = [
    ...
    path('api/token/', TokenObtainPairWithFullUserView.as_view(), name='token_obtain_pair'),
    ...
]

The TokenObtainPairWithFullUserView is a subclass of TokenObtainPairView with the TokenObtainPairWithFullUserSerializer serializer.


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drf-simplejwt-additions-1.0.1.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

drf_simplejwt_additions-1.0.1-py3-none-any.whl (3.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page