Home > Back-end >  Django JWT Auth for custom model
Django JWT Auth for custom model

Time:04-18

I have a custom user model

class User(models.Model):
    fields...

It also has a email, password field among other detail fields. I want to use the simplejwt JWT authorization which takes email and password as input and generates JWT Tokens. Most tutorials include creating a superuser and passing username password of the superuser to get the token, But I want to do this for my custom user model.

CodePudding user response:

REST implementation of Django authentication system. DJOSER

A sample look

CodePudding user response:

django-simple-jwt generates the access and refresh tokens through the obtainTokenPairView. This views calls the authenticate function from django. Therefore if you have set up a custom user model following django guidelines, to use the email in place of the username, django-simple-jwt should work out of the box

Otherwise, you still have the option to create your own view and Generate the tokens manually

  • Related