簡體   English   中英

Magento 2 rest api拋出401 Unauthorized錯誤

[英]Magento 2 rest api throws 401 Unauthorized error

我在Magento 2中創建了一個用戶角色,並創建了一個新的用戶圖像捕獲

我在Chrome中使用了郵遞員的應用程序:

在GET框中: http//example.com/php.index/rest/V1/products/在類型中使用基本身份驗證,用戶名和密碼

但我得到這個狀態'401 Unauthorized'並且這個請求:

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

我可以使用用戶名和密碼登錄Magento后端

有解決方案嗎

您需要在標頭中使用訪問密鑰傳遞基本授權:

第1步:

使用參數調用API: / V1 / integration / admin / token

username=your_admin_username
password=your_admin_password

這將為您提供一個訪問密鑰,如at0o6w5rhno6sltcuhf3 **** k0603l

第2步:

調用API: / V1 / products / with parameters

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM