2
votes

I'm using django-rest-framework and mongoengine as the backend framework for my REST API's and Angular JS as the front end. How can implement JSON Web Token (JWT) authentication with a custom User document?. I have checked this link https://jpadilla.github.io/django-rest-framework-jwt/. But it supports only django-rest with Auth User model. How shud I proceed with this? Should I try implementing it using the python library https://pyjwt.readthedocs.org/en/latest/installation.html ?. All suggestions are welcome. Thank You.

1

1 Answers

2
votes

You might want to configure in your settings file that

AUTH_USER_MODEL = 'your_custom_user_class

See https://docs.djangoproject.com/en/3.0/topics/auth/customizing/#substituting-a-custom-user-model

You could then go on to use Django Rest Framework's authentication classes:

REST_FRAMEWORK = {
    ...
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
    ),
    ...
}