Search code examples
pythondjangoauthenticationdjango-rest-frameworkhttp-token-authentication

Get user object from token string in DRF?


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?


Solution

  • from rest_framework.authtoken.models import Token
    user = Token.objects.get(key='token string').user