更改 Magento 2.1 来宾访问网络的权限 api catalog/products

Change Magento 2.1 guest permissions to access web api catalog/products

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

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.