2π
β
In DRF user should be authenticated inside Authentication class. This library provides one for JWT auth. It provides both token generation and verification.
You will get user as self.request.user
in your View or ViewSet class. You just need to allow JWT auth:
class ExampleView(APIView):
authentication_classes = (BasicAuthentication, JSONWebTokenAuthentication)
Or better set is as DEFAULT_AUTHENTICATION_CLASSES
as documented here.
π€Raz
Source:stackexchange.com