I am trying to use Token Authentication from Django Rest Framework.

I followed all the instruction such as:

1. Adding these lines into installed apps:


2. Adding statement into settings:


I am sending HTTP request with header 'Authorization': 'Token token_name', where token_name is token of corresponding user which I can see in a database.

On a server, request.user still returns AnonymousUser and request.user.is_authenticated is False. What can be the issue ?

This is the corresponding view code:

def test(request):
    return HttpResponse('ok')

This is corresponding line from urlpatterns:

path('test/', views.test)

0 Answers