I am able to set up the OAuth2 server using the tutorial(https://django-oauth-toolkit.readthedocs.io/en/latest/install.html).
I am using an existing user model to set up the Auth code grant. I need to use the custom table (which has userId, password fields only). But Authenticate backend looks for user table configuration. Is there any way we can remove the user table and use custom table for authentication.?
Please help on this problem
Django-oauth-toolkit uses AUTH_USER_MODEL from settings, so it's matter of customizing user model by reading https://docs.djangoproject.com/en/3.0/topics/auth/customizing/
Thanks for the reply. I am new to django. Customizing the user model is adding additional fields in the model or modifing user model. And user model has so many fields such as is_active, email, first name , last name which is not required for my case. I am looking to store username , unique I'd which will be stored in customer table. And I want use this customer table to authenticate the customer to generate the to token. Can we achieve this kind of solution..?
As far I understand the problem. You want Customer (model) to be your User (model) and without the necessary fields such as is_active.
In django, you can inherit the AbstractBaseUser
https://docs.djangoproject.com/en/3.0/topics/auth/customizing/
models.py
class Customer(AbstractBaseUser):
# do something here
and said above by @dulmandakh change AUTH_USER_MODELS in settings by your user model e.g AUTH_USER_MODELS = 'app.Customer'
noting Inheriting without extensive knowledge could be a pain in the ass.
You can still use the default User tho and not use the remaining fields since it was not required.
Most helpful comment
Django-oauth-toolkit uses AUTH_USER_MODEL from settings, so it's matter of customizing user model by reading https://docs.djangoproject.com/en/3.0/topics/auth/customizing/