Get user object from token string in DRF?

后端 未结 5 952
逝去的感伤
逝去的感伤 2021-02-09 16:36

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:47

    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.

提交回复
热议问题