jpadilla / django-rest-framework-jwt

JSON Web Token Authentication support for Django REST Framework
http://jpadilla.github.io/django-rest-framework-jwt/
MIT License
3.19k stars 652 forks source link

Allow mapping payload username field to actual #309

Open willdady opened 7 years ago

willdady commented 7 years ago

I have a custom User model where USERNAME_FIELD = 'email' however I'd like to be able to submit login credentials as:

{
  username: 'foo@example.com',
  password: 'mypassword'
}

Not

{
  email: 'foo@example.com',
  password: 'mypassword'
}

I'm wanting to make the request compliant with OAuth2 Access Token Request.

Currently this is not possible as JSONWebTokenSerializer creates it's username field by inspecting UserModel.USERNAME_FIELD. Having a setting for mapping payload username to model username would be useful.

avral commented 7 years ago

Same problem :(