We use JWT Token with Django REST Framework. Where store JWT Token and I want to store JWT Token in my DB. Because I used this API for mobile app.
Here create JWT Token
class LoginView(APIView):
permission_classes = [permissions.AllowAny]
def post(self, request, format=None):
"""
Return a Valid token if username and password
is valid for a given client
"""
try:
username = request.data['username']
password = request.data['password']
user = authenticate(username=user.username, password=password)
if user is not None:
if user.is_active:
login(request, user)
jwt_payload_handler = api_settings.JWT_PAYLOAD_HANDLER
jwt_encode_handler = api_settings.JWT_ENCODE_HANDLER
payload = jwt_payload_handler(user)
token = jwt_encode_handler(payload)
ind = Individual.objects.filter(user_id=user.id).first()
ind.login_flag = True
ind.save()
here, I used JWT Token Verification
class LogoutView(APIView):
permission_classes = (IsAuthenticated, )
authentication_classes = (JSONWebTokenAuthentication, )
def post(self, request, format=None):
.......
.......
Its working proper with JWT Token verification on postman. But I want to where store token and How to store JWT Token in my DB.