我正在使用在github上找到的Django rest框架JSON Web令牌API(https://github.com/GetBlimp/django-rest-framework-jwt/tree/master/)。如何删除django JWT令牌?
我可以成功创建令牌并使用它们来调用受保护的REST APis。但是,在某些情况下,我想在特定的令牌到期之前删除特定的令牌。所以我想这样做的观点如下:
class Logout(APIView):
permission_classes = (IsAuthenticated,)
authentication_classes = (JSONWebTokenAuthentication,)
def post(self, request):
# simply delete the token to force a login
request.auth.delete() # This will not work
return Response(status=status.HTTP_200_OK)
request.auth
只是一个字符串对象。所以,这当然不起作用,但我不确定如何清除潜在的令牌。
编辑
阅读更多关于这一点,似乎我不需要做任何事情如无物都保存在智威汤逊在服务器端。因此,关闭应用程序并在下次登录时重新生成令牌就足够了。那是对的吗?