首页 > 解决方案 > 如何在 magento 2 中使用 REST API 获取所有类别而无需任何登录名或令牌?

问题描述

使用 Admin Token 类别将出现在 rest API 中,但没有 token 对如何在 magento 2 中获取所有没有 token 的类别没有任何解决方案

标签: magento2

解决方案


默认情况下,Magento 2 允许在没有身份验证的情况下访问少数端点,这些端点被声明为anonymous资源。例如,V1/directory/currency无需V1/directory/countries任何身份验证即可访问。

但是,当用户需要访问非匿名端点时。此选项 ( Allow Anonymous Guest Access) 必须启用:

Stores > Settings > Configuration > Services > Magento Web API > Web API Security > Allow Anonymous Guest Access

现在,可以使用此端点获得无需身份验证的类别。

http://example.com/rest/V1/categories

注意:不建议在没有身份验证的情况下使用 Magento 2 REST API。


推荐阅读