[英]Django Authentication credentials were not provided
So I'm using Http file to make GET request using rest_framework
Authentication 所以我正在使用Http文件使用
rest_framework
身份验证进行GET请求
here is the command I use: 这是我使用的命令:
GET localhost:8000/api-admin/products
Authorization: Token 5e2cf6ddc7a0ff8fe03e4749d788a423f6640443
When I use the browser and go to that link it works successfully but when I use HTTP file or Postman I get Authentication credentials were not provided.
当我使用浏览器并转到该链接时,它可以成功工作,但是当我使用HTTP文件或邮递员时,我
Authentication credentials were not provided.
error 错误
Also I added the code in settings file 我也在设置文件中添加了代码
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
)
}
我认为您必须在URL末尾添加尾随/。
The error was that I forgot to add TokenAuthentication
in the authentication_classes
错误是我忘记在
authentication_classes
添加TokenAuthentication
authentication_classes = (SessionAuthentication, BasicAuthentication, TokenAuthentication)
inside the API file 在API文件中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.