Djangorestframework-simplejwt: Authentication using username or email

Created on 24 Jan 2019  Â·  6Comments  Â·  Source: jazzband/djangorestframework-simplejwt

it is not supporting username_or_email and password for authentication. Any settings to authenticate using username as well as email?

Most helpful comment

@whatcould Right. The login serializer just uses the username field defined on the user model. I don't think there's any way it could properly account for the behavior of non-standard authentication backends.

All 6 comments

+1 from me. However, I don't think this is an issue but rather a feature?

Authentication is done using the authenticate method of django.contrib.auth. Therefore you can modify its behaviour by modifying the AUTHENTICATION_BACKENDS setting in settings.py.

Your question has nothing to do with this package, please close.

What @gabn88 says is correct, actually. Take a look here. Will close this since it seems out of scope for simple jwt.

For others with this issue: In an existing app with multiple authentication backends (including login by email), I was confused when I passed "email" and "password" fields and DRF-simplejwt returned {"username":["This field is required."]}.

All I had to do was pass the email as the username — don't change the field name to 'email'.

@whatcould Right. The login serializer just uses the username field defined on the user model. I don't think there's any way it could properly account for the behavior of non-standard authentication backends.

Based on stackowerflow answer https://stackoverflow.com/questions/37332190/django-login-with-email

use this link for update default User model and change username field to email
https://stackoverflow.com/questions/37332190/django-login-with-email

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nikolaik picture nikolaik  Â·  4Comments

naelmusleh picture naelmusleh  Â·  4Comments

mjackstone6 picture mjackstone6  Â·  4Comments

ethanjahn picture ethanjahn  Â·  7Comments

mosi-kha picture mosi-kha  Â·  6Comments