2016-11-15 91 views
4

我正在使用在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只是一個字符串對象。所以,這當然不起作用,但我不確定如何清除潛在的令牌。

編輯

閱讀更多關於這一點,似乎我不需要做任何事情如無物都保存在智威湯遜在服務器端。因此,關閉應用程序並在下次登錄時重新生成令牌就足夠了。那是對的嗎?

回答