简体   繁体   English

尝试使用Loopback API注销时获得401

[英]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.

相关问题 尝试使用访问令牌访问Spotify Web API时获取401 - Getting 401 when trying to access spotify web api with access token 从环回删除数据时得到401(未经授权)? - Getting 401 (Unauthorized) when deleting data from loopback? 用户模型环回中出现401错误 - Getting 401 error in loopback with User Model 环回中的角色无法正常工作,出现错误 401 - Role in loopback not working properly getting error 401 尝试登录我的应用程序时不断收到 401 错误 - I keep getting a 401 error when trying to login to my app 尝试在 findOne 和 Node api 中执行 where 过滤器在环回中按 id 过滤时返回空数组 - Trying to do a where filter in findOne and in Node api returns empty array when filtering by ids in loopback 环回-资源管理器中未显示自定义Api - Loopback - Custom Api not getting displayed in explorer 环回API:响应在压缩时陷入困境 - Loopback API: Response getting stuck at compression LoopBack 4 REST API示例,用于通过Mysql获取记录 - LoopBack 4 REST API example for getting record with Mysql nodejs - 尝试使用 Google Drive API 导出链接下载文档修订时出现 401 错误 - nodejs - Getting 401 error trying to download docs revisions with Google Drive API export links
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM