[英]Django Authentication credentials were not provided
所以我正在使用Http文件使用rest_framework
身份验证进行GET请求
这是我使用的命令:
GET localhost:8000/api-admin/products
Authorization: Token 5e2cf6ddc7a0ff8fe03e4749d788a423f6640443
当我使用浏览器并转到该链接时,它可以成功工作,但是当我使用HTTP文件或邮递员时,我Authentication credentials were not provided.
错误
我也在设置文件中添加了代码
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
)
}
我认为您必须在URL末尾添加尾随/。
错误是我忘记在authentication_classes
添加TokenAuthentication
authentication_classes = (SessionAuthentication, BasicAuthentication, TokenAuthentication)
在API文件中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.