Setup the Login Function and api route Here we have created a login function which handled the POST request and get username and password as params and then authenticate them if they are correct then return the token if they are correct else return the not found response. map the /api/login route with our function.
Read moreWhich authentication is best for Django REST Framework?
I personally would recommend a token-based authentication , so you don’t have to worry about clients intercepting user’s credentials.
Read moreHow do I authenticate in Django?
User authentication in Django
Read moreHow does Django REST Framework authentication work?
Authentication is the mechanism of associating an incoming request with a set of identifying credentials, such as the user the request came from, or the token that it was signed with . The permission and throttling policies can then use those credentials to determine if the request should be permitted.
Read more