[Answer]-Django rest framework TokenAuthentication not working

1👍

Problem :

class MyList(generics.ListCreateAPIView):

    queryset = MyMod.objects.all()
    serializer_class = MyListSerializer
    authentication_classes = (TokenAuthentication,)

Solution:

class MyList(generics.ListCreateAPIView):

    queryset = MyMod.objects.all()
    serializer_class = MyListSerializer
    permission_classes = [TokenHasReadWriteScope]

curl -H “Authorization: Bearer MDgYnKeoRsp0O4Hfgr9ka5tdfkKs6Y” http://127.0.0.1:8000

Leave a comment