Here is my API in Django REST.
Here is my code:
from rest_framework.permissions import IsAuthenticated, AllowAny
class CreateItems(generics.CreateAPIView):
permission_classes = [IsAuthenticated]
queryset = SomeModel.objects.all()
serializer_class = SomeSerializer
class AuthStatus(APIView):
permission_classes = [AllowAny]
def post(self, request, *args, **kwargs):
token = self.request.data['itemsReturnedAuthAPI']['auth-token']
if(token):
return Response({"Token":token})
else:
return Response({"message":"No Token Found!"})
I have an authentication microservice that I get the JWT Token from for the user in order to have access to the views. In the AuthStatus class I am checking the token.
My Question: I want to grant the user access to the CreateItems class, after the token is provided