[Answered ]-DRF and Knox showing logged in user as anonymous (Django)

1👍

from knox.auth import TokenAuthentication
token = request.META.get('HTTP_AUTHORIZATION', False)
if token:
    token = str(token).split()[1].encode("utf-8")
    knoxAuth = TokenAuthentication()
    user, auth_token = knoxAuth.authenticate_credentials(token)
    request.user = user

Leave a comment