Get user object from token string in DRF?

后端 未结 5 987
说谎
说谎 2021-02-09 16:01

I have a token string from Django REST Framework\'s TokenAuthentication.

I need to get the corresponding user object. How would I go about doing this?

5条回答
  •  逝去的感伤
    2021-02-09 16:42

    A better method to use would be to simply call request.user since access to the Token means an authenticated request. DjangoRestFramework gives access to request.auth and request.user on a successful TokenAuthentication.

提交回复
热议问题