相关疑难解决方法(0)

Django:Rest Framework验证头

使用Django REST API,我正在尝试验证我的请求.

这就是我要发送的内容:

Content-Type: application/json, Authentication: token="6d82549b48a8b079f618ee9c51a6dfb59c7e2196"
Run Code Online (Sandbox Code Playgroud)

这就是我得到的回报:

{"detail": "Authentication credentials were not provided."}
Run Code Online (Sandbox Code Playgroud)

有人能给我正确的标题吗?

谢谢

标题:

Accept: application/json
Content-Type: application/json
Authorization: Token 6d82549b48a8b079f618ee9c51a6dfb59c7e2196
Connection: keep-alive
Origin: chrome-extension: //rest-console-id
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Settings.py

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
        'rest_framework.permissions.IsAdminUser',


    ),
    'PAGINATE_BY': 10
}
Run Code Online (Sandbox Code Playgroud)

view.py

class ProfileList(generics.ListCreateAPIView):
    """
    API endpoint that represents a list of users.
    """
    permission_classes = (permissions.IsAuthenticated,)
    model = Profile
    serializer_class = ProfileSerializer

    def …
Run Code Online (Sandbox Code Playgroud)

django django-rest-framework

42
推荐指数
4
解决办法
3万
查看次数

标签 统计

django ×1

django-rest-framework ×1