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