【发布时间】:2019-07-10 02:55:30
【问题描述】:
我正在使用带有 React 的 Django,我可以使用 http://127.0.0.1:8000/rest-auth/login/' 登录用户并使用 http://127.0.0.1:8000/rest-auth/registration/ 注册用户
我正在尝试获取当前用户:
axios.get('http://127.0.0.1:8000/rest-auth/user/')
.then(res => {
console.log(res)
})
但我收到以下错误:
GET http://127.0.0.1:8000/rest-auth/user/ 403 (Forbidden)
我也在邮递员上试过,得到以下结果:
{
"detail": "Authentication credentials were not provided."
}
有人可以告诉我正确的方法吗?提前致谢。
【问题讨论】:
-
您能否检查请求并查看会话 cookie 是否与请求一起发送?
标签: django django-rest-framework