Запрещено (CSRF cookie не установлен.): /auth для получения_auth_token

Я пытаюсь получить токен аутентификации для клиента (OrderClient.py). Это все время приводит к ошибке Forbidden (CSRF cookie не установлен.): /auth. Вот мои представления

from rest_framework.decorators import api_view,permission_classes,authentication_classes
from rest_framework.response import Response
from .serializers import OrderSerial
from rest_framework.authentication import SessionAuthentication, TokenAuthentication
from rest_framework.permissions import IsAuthenticated

@api_view(['POST'])
@authentication_classes([SessionAuthentication, TokenAuthentication])
@permission_classes([IsAuthenticated])
def make_order(request,*args,**kwargs):
    user1=request.user

    serializer = OrderSerial(user=user1)
    print(serializer.is_valid())
    data={'abc':'cde'}
    return Response(data=data)

Вот мой urls.py

from django.urls import path
from Products.views import home_view,Phone_input_view,Phone_list_view,Phone_edit_view
from Products.api.views import make_order
from rest_framework.authtoken.views import obtain_auth_token

urlpatterns = [
    path('',home_view),
    path('auth/', obtain_auth_token),
    path('createPhone/',Phone_input_view),
    path('viewPhoneList/',Phone_list_view),
    path('edit/<int:id>',Phone_edit_view),
    path('order/', make_order)
]

Я добавил 'rest_framework.authtoken' к установленным приложениям в настройках.

Я ожидал получить токен и успешно войти в систему

Вернуться на верх