i am trying to verify and decode simple-jwt-django-rest-framework token. I know we can use verify api of simple-jwt. But i want to decode and verify in my views . Below is the current code i am trying:-
//in views.py
class home(APIView):
def post(self,request,*args,**kwargs):
print("request is ",request._request)
verify_token_response = token_verify(request._request)
print("status_code is ", verify_token_response.status_code)
if(verify_token_response.status_code == 200):
jwt_object = JWTAuthentication()
validated_token = jwt_object.get_validated_token(request._request)
user = jwt_object.get_user(validated_token)
print(user)
return Response({
'status':True,
'message':'home'
})
This code is working for me for token validation. It is validating token correctly , but when i am retrieving the valiated_token and user , it giving me error of :-
{
"detail": "Given token not valid for any token type",
"code": "token_not_valid",
"messages": [
{
"token_class": "AccessToken",
"token_type": "access",
"message": "Token is invalid or expired"
}
]
}