Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django Rest框架身份验证被拒绝_Python_Django_Django Rest Framework - Fatal编程技术网

Python Django Rest框架身份验证被拒绝

Python Django Rest框架身份验证被拒绝,python,django,django-rest-framework,Python,Django,Django Rest Framework,我已经使用PSA在Django上验证了我的用户,并在用户模型中注册了用户,甚至令牌模型也注册了用户和令牌 但当我发送此请求时: curl -X POST -H "Authorization:Token 87e939184457ccc064485444a90e3ebf417xxxxx" http://192.168.x.x:8000/user-profiles/>error.html 我明白了 {“详细信息”:“您没有执行此操作的权限。”} 如果我发这个: curl -X POST --

我已经使用PSA在Django上验证了我的用户,并在用户模型中注册了用户,甚至令牌模型也注册了用户和令牌

但当我发送此请求时:

curl -X POST -H "Authorization:Token 87e939184457ccc064485444a90e3ebf417xxxxx" http://192.168.x.x:8000/user-profiles/>error.html 
我明白了

{“详细信息”:“您没有执行此操作的权限。”}

如果我发这个:

curl -X POST --user "VedantDasSwain:87e939184457ccc064485444a90e3ebf417xxxxx" http://192.168.x.x:8000/user-profiles/>error.html 
我明白了

{“详细信息”:“无效的用户名/密码”}

以下是我的设置文件中的相关片段:

'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',
        'rest_framework.permissions.IsAdminUser',),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.TokenAuthentication',
    ),
这是PSA设置的一部分:

AUTHENTICATION_BACKENDS = (
    'social.backends.facebook.FacebookOAuth2',

    'django.contrib.auth.backends.ModelBackend',
)

以前有人遇到过这种情况吗?这个问题的解决方案是什么?

我的印象是,这个元组意味着要么是经过身份验证的用户,要么是管理员

'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated',
        'rest_framework.permissions.IsAdminUser',)
但是,我从元组中删除了“rest\u framework.permissions.isadmin用户”,然后它在上给出了正确的结果

curl -X POST -H "Authorization:Token 87e939184457ccc064485444a90e3ebf417xxxxx" http://192.168.x.x:8000/user-profiles/>error.html 
我不知道为什么会这样。这几乎是侥幸。如果有人知道为什么会这样,请告诉我