"The consumer isn't authorized to access %resources." error message comes when the API end point resource is "Self" so for this you need to pass customer token in that API not only in this API but in every "Self" resource API.
As we know there are 3 types of resource in Magento API:
- Administrator or Integration
Resources for which administrators or integrator are authorised. For example, if administrators are authorised for the Magento_Customer::group resource, they can make a GET /V1/customerGroups/:id call.
- Customer : Resources with "anonymous" or "self" permission.
- Guest user : Resources with anonymous permission
so there are 3 types or resources when you check the end point which you are hitting you will see in it's webapi.xml file that resource type is self which is number 2 point.
For This you need to generate a customer token using magento default Customer Token API using below end point:
and need to pass below request Parameter:
"username": "pass customer email id",
"password": "pass customer password",
"device":"Device type from which you login"
Once you pass these and hit this POST API then it will return a token for you then you just need to pass it in you API header where you were facing the error to pass in header you have to pass it like:
Authorization :bearer<space><the token generated for customer>
once you do this API will hit.
for more information about resources you can follow Authentication Dev Docs by Magento.
PS: This customer Token generate automatically when customer get login so you just need to pass that token in all those API which are "self" type.