如何从Django Rest Framework JWT令牌获取用户名 [英] How to get username from Django Rest Framework JWT token
本文介绍了如何从Django Rest Framework JWT令牌获取用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Django Rest Framework,并且包含了一个名为
I am using Django Rest Framework and i've included a 3rd party package called REST framework JWT Auth. It returns a token when you send a username/password to a certain route. Then the token is needed for permission to certain routes. However, how do I get the username from the token? I've looked all through the package documentation and went through StackOverflow. It is a JSON Web Token and I am assuming there is a method like username = decode_token(token)
but I haven't found such a method.
推荐答案
基本上,您可以这样做
username = request.user.username
这篇关于如何从Django Rest Framework JWT令牌获取用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文