from rest_framework.authtoken.models import Token
class getTokenl(generics.RetrieveDestroyAPIView):
permission_classes = [permissions.IsAuthenticated, TokenHasReadWriteScope]
queryset = Parcel.objects.all()
serializer_class = ParcelGetSerializer
model=Parcel
def dispatch(self, request, *args, **kwargs):
tok=request.META['HTTP_AUTHORIZATION'].replace('Bearer ','')
print (Token.objects.get(authtoken=tok))
With this, I get a error:type object 'Token' has no attribute 'objects'
How do I get the token object? More so, is this the best way to access token object. at the end, I would like to get to the user who owns that token. Appreciate any help.
- Shekar