2016-04-11 135 views
1

我已创建在Magento 2用户角色和新用户 image captureMagento的2 REST API抛出401未经授权错误

我在Chrome中使用的应用程序邮差:

在GET框:http://example.com/php.index/rest/V1/products/ 在类型使用基本身份验证用户名和密码

但我得到这个状态“401未授权”,这要求:

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

我可以使用用户名和密码登录Magento后端

任何解决方案?

回答

0

您需要通过基本授权与头快捷键:

第1步:

调用API:/V1 /集成/管理/令牌与参数:

username=your_admin_username 
password=your_admin_password 

这会给你一个访问键,如at0o6w5rhno6sltcuhf3 **** k0603l

第二步:

调用API:/V1 /产品/与参数

searchCriteria=* 
Put **Header** 
Authorization : Bearer at0o6w5rhno6sltcuhf3****k0603l 
Content-Type : application/json 
相关问题