0

I am trying to get result for the existing magento api service ex.customer details (or) product details by sku, I am facing issue like below, give solution

"message": "Consumer is not authorized to access %resources",
"parameters": {
    "resources": "Magento_Customer::customer"
}
4
  • Magento is using resource Magento_Customer::customer for this and because of this we can't access it using Customer's token so for the same we need to override Specific API with OR Use Admin token for the same. Jul 31, 2018 at 6:41
  • Hello @SUBBULAKSHMI G, please check the answer. Jul 31, 2018 at 7:03
  • How can I get admin token? how to execute in Postman? Jul 31, 2018 at 7:05
  • if any answer solves your concern then please mark as right for future readers, or post your own solution. Sep 20, 2018 at 12:03

1 Answer 1

1

Endpoint

POST http://<host>/rest/default/V1/integration/admin/token

Header

Content-Type application/json

Payload

{
"username": "admin",
"password": "123123q"
}

Response

Magento returns the admin’s access token.

  • This token must be specified in the authorization header of every call that requires admin permissions.

Magento is using resource Magento_Customer::customer for this and because of this we can't access it using Customer's token so for the same we need to override Specific API with OR you need to use Admin's token

<resource ref="self" />

And using this we can access all data of a specific customer using customer's Token in Magento API.

OR you need to use Admin token instead of customer token

  • and if you want to use customer token then you need to change webapi.xml resource

For an example : Customer data

   <!-- Customer Account -->
<route url="/V1/customers/:customerId" method="GET">
    <service class="Magento\Customer\Api\CustomerRepositoryInterface" method="getById"/>
    <resources>
        <resource ref="self"/>
    </resources>
</route>

I replaced resource <resource ref="Magento_Customer::customer"/> to <resource ref="self"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.