With reference to the documentation, https://www.django-rest-framework.org/api-guide/authentication/#how-authentication-is-determined I was trying to use CustomAuthToken, in my app view and import it in url
from rest_framework.authtoken.views import ObtainAuthTokenfrom rest_framework.authtoken.models import Tokenfrom rest_framework.response import Response class CustomAuthToken(ObtainAuthToken): def post(self, request, *args, **kwargs): serializer = self.serializer_class(data=request.data, context={'request': request}) serializer.is_valid(raise_exception=True) user = serializer.validated_data['user'] token, created = Token.objects.get_or_create(user=user) return Response({ 'token': token.key, 'user_id': user.pk, 'email': user.email }) But it giving circular import error my project without customAuth - https://github.com/shubham1507/school/blob/master/users/views.py -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ae544aef-3651-48b7-96eb-1af697c4b63c%40googlegroups.com.