rest - 更改 Magento 2.1 guest 权限以访问 Web api 目录/产品

标签 rest api magento magento2 user-permissions

我想更改匿名角色(访客)的权限设置,以便无需任何身份验证即可查看所有产品。

http://magento.dev/rest/V1/products

我明白,我可以编辑:

/magento/vendor/magento/module-catalog/etc/webapi.xml

允许匿名访问,但这看起来很黑客。

当我尝试此端点时:

http://magento.dev/rest/V1/products

我得到以下结果:

{
  "message": "Consumer is not authorized to access %resources",
  "parameters": {
    "resources": "Magento_Catalog::products"
  }
}

我是 Magento 新手,所以这种 REST api 方法可能是错误的,还有另一种方法可以在不提升权限的情况下检索 JSON 格式的产品列表。

提前致谢。

最佳答案

在 Magento 2.1 中。对许多端点的匿名访问已受到限制。您可以禁用此限制,according to the documentation:

To disable this feature, log in to the Admin panel and navigate to Stores > Configuration > Services > Magento Web API > Web API Security. Then select Yes from the Allow Anonymous Guest Access menu.

关于rest - 更改 Magento 2.1 guest 权限以访问 Web api 目录/产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39172887/

相关文章:

rest - Acumatica REST API - 删除 SalesOrderDetail

php - Magento API v2 PHP 错误

java - 如何解析获取请求响应以获取所有键和值对?

Magento - 分页生成错误的 URL

Magento:不一致的 URL 重写

java - 使用 Java/Jersey 作为 REST 和 SOAP 工作的 Web 服务

java - 与具有路径变量的单个端点相比,拥有单独的端点是否有优势?

linux - Magento 1.7 - 一台服务器中的两个magento相互影响

java - WCF 服务始终在响应正文中返回随机数

java - 我如何使用java创建Facebook帐户