You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
I just have one small problem. My API uses a custom User model which does not have a username, only email.
I have an application using grant_type="password"
Django-oauth-toolkit supports this and if I call the django-oauth-toolkit route /o/token with username=[email protected] it understands it and I can get a token
However if I use your endpoint /auth/token I get 'User' object has no attribute 'username'
My User model for reference:
class User(AbstractBaseUser, PermissionsMixin):
"""The User model with email as a "username"."""
email = models.EmailField(_('email address'), unique=True)
name = models.CharField(max_length=255, blank=True)
is_staff = models.BooleanField(
_('staff status'),
default=False,
help_text=_(
'Designates whether the user can log into this admin site.',
),
)
is_active = models.BooleanField(
_('active'),
default=True,
help_text=_(
'Designates whether this user should be treated as active. ' +
'Unselect this instead of deleting accounts.',
),
)
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
date_added = models.DateTimeField(auto_now_add=True)
date_updated = models.DateTimeField(auto_now=True)
EMAIL_FIELD = 'email'
USERNAME_FIELD = 'email'
REQUIRED_FIELDS: list[str] = []
objects = UserManager()
class Meta(object):
verbose_name = _('user')
verbose_name_plural = _('users')
def clean(self):
"""Normalize the email before save."""
super().clean()
self.email = self.__class__.objects.normalize_email(self.email) # noqa: WPS601, E501
def __str__(self) -> str: # noqa: D105
return textwrap.shorten(
text=self.name or self.email,
width=40, # noqa: WPS432
placeholder='...',
)
Do you know any workaround for me with this problem?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, thanks for this library!
I just have one small problem. My API uses a custom User model which does not have a username, only email.
I have an application using
grant_type="password"
Django-oauth-toolkit supports this and if I call the django-oauth-toolkit route
/o/token
with username=[email protected] it understands it and I can get a tokenHowever if I use your endpoint
/auth/token
I get'User' object has no attribute 'username'
My User model for reference:
Do you know any workaround for me with this problem?
The text was updated successfully, but these errors were encountered: