loopback错误AUTHORIZATION_REQUIRED statusCode 401

时间:2016-09-02 11:26:49

标签: node.js loopbackjs loopback

我面临问题,我的模型名为提供商,我称之为 GET 方法:

{
  "error": {
    "name": "Error",
    "status": 401,
    "message": "Authorization Required",
    "statusCode": 401,
    "code": "AUTHORIZATION_REQUIRED",
    "stack": "Error: Authorization Required\n    at /home/developer/node_modules/loopback/lib/application.js:396:21\n    at /home/developer/node_modules/loopback/lib/model.js:322:7\n    at /home/developer/node_modules/loopback/common/models/acl.js:472:23\n    at /home/developer/node_modules/async/dist/async.js:3679:13\n    at /home/developer/node_modules/async/dist/async.js:952:25\n    at iteratorCallback (/home/developer/node_modules/async/dist/async.js:997:17)\n    at /home/developer/node_modules/async/dist/async.js:847:20\n    at /home/developer/node_modules/async/dist/async.js:3676:17\n    at /home/developer/node_modules/async/dist/async.js:339:31\n    at /home/developer/node_modules/loopback/common/models/acl.js:454:17\n    at /home/developer/node_modules/loopback/common/models/role.js:272:21\n    at /home/developer/node_modules/async-listener/glue.js:188:31\n    at _combinedTickCallback (internal/process/next_tick.js:67:7)\n    at process._tickDomainCallback [as _tickCallback] (internal/process/next_tick.js:122:9)"
  }
}

我正在与开发人员放弃其项目的客户打交道。因为我是LOOPBACK的新手,所以我完全感到困惑,所以非常需要你的帮助...

提前致谢...

1 个答案:

答案 0 :(得分:1)

检查您的模型common/models/Provider.json文件

添加特定方法权限:

"acls": [
    {
      "principalType": "ROLE",
      "principalId": "$everyone",
      "permission": "ALLOW"
    }
]

这将使所有模型方法公开而不进行任何身份验证,有关ACL的更多信息,请阅读文档:

https://docs.strongloop.com/display/public/LB/Controlling+data+access