I am trying to use the Magento 2 rest API, but even when just curl'ing from command line, the only response I get is Consumer is not authorized to access %resources
I managed to get a token with
curl -X POST "http://magento.dev.blackorange.nl/index.php/rest/V1/integration/admin/token" \
-H "Content-Type:application/json" \
-d '{"username":"adminuser", "password":"adminpass"}'`
but when i try
curl -X GET -H "Authorization: Bearer TOKEN" "http://magento.dev.blackorange.nl/rest/V1/products"
(or any other endpoint) I get the-the Consumer is not authorized to access %resources
message
Am I missing a step somewhere?
make sure you are using Magento2 admin username password not any API Username Password With proper roles are assigned to that user , if this does not work try changing the ROLE : ALL
to access GET /V1/products you need to pass searchCriteria parameter its required parameter.
1st you need to call admin/token API the token you get from here you need to pass in 2nd API
replace TOKEN with your token Key from 1st Call
curl -X GET -H "Authorization: Bearer ntfw****avefg***6mil***kysnl3***" "http://magento.dev.blackorange.nl/rest/V1/products"
for all REST API Reference : http://devdocs.magento.com/swagger/index.html#/
Try it with trimming the token value. It gets blank space which makes it incorrect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With