[英]Getting a 401 when trying to logout with Loopback API
I've got a Loopback js api and a Vue js app that I'm trying to get to talk to each other, but I'm getting a weird error. 我有一个Loopback js API和一个Vue js应用程序,我想互相交流,但是出现一个奇怪的错误。 I'm trying to POST logout from my Vue app, but it keeps giving me a 401 even though it works fine when I do it from the Loopback api explorer.
我正在尝试从Vue应用程序中注销,但是即使从Loopback api资源管理器中执行它时,它仍然可以正常工作,但它始终为我提供401。
My request is to http://localhost:3000/api/employees/logout
with payload access_token : "XXX"
where employees is my model extending User. 我的请求是使用有效负载
access_token : "XXX"
到http://localhost:3000/api/employees/logout
,其中员工是我扩展用户的模型。
The code making the client-side request is 发出客户端请求的代码是
axios.post(`${store.api.url}/employees/logout`, {
access_token: store.state.authentication.auth.id
})
.then(() => {
store.commit('resetAuth');
this.$router.push({ name: 'login' });
})
.catch((error) => {
console.log(error);
});
And yes, I am authenticated and the token does exist on the other end. 是的,我已通过身份验证,并且令牌确实存在于另一端。 Any help would be appreciated.
任何帮助,将不胜感激。
So apparently it was permissions -_- 显然是权限-_-
If you don't have permission to access an object, even if you are authenticated, it returns a 401, not a 403 like I was expecting. 如果您没有访问对象的权限,即使您已通过身份验证,它也会返回401,而不是我期望的403。
did you add authentication.js script to server/boot and re check ACL for employee model ? 您是否在服务器/引导中添加了authentication.js脚本并重新检查了员工模型的ACL? Those are the loose ends in certain problems, I guess.
我想,这些只是某些问题的徒劳。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.