I created a new customer and got the token perfectly but when I try to access any API like


got the error

<?xml version="1.0"?>
<message>Consumer is not authorized to access %resources</message>
  <trace>#0 /var/www/myhost.com/public_html/vendor/magento/module-webapi/Controller/Rest/RequestValidator.php(70): Magento\Webapi\Controller\Rest\RequestValidator-&gt;checkPermissions()
#1 /var/www/myhost.com/public_html/vendor/magento/module-webapi/Controller/Rest/InputParamsResolver.php(80): Magento\Webapi\Controller\Rest\RequestValidator-&gt;validate()
#2 /var/www/myhost.com/public_html/vendor/magento/module-webapi/Controller/Rest.php(299): Magento\Webapi\Controller\Rest\InputParamsResolver-&gt;resolve()
#3 /var/www/myhost.com/public_html/vendor/magento/module-webapi/Controller/Rest.php(216): Magento\Webapi\Controller\Rest-&gt;processApiRequest()
#4 /var/www/myhost.com/public_html/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(24): Magento\Webapi\Controller\Rest-&gt;dispatch(Object(Magento\Framework\App\Request\Http))
#5 /var/www/myhost.com/public_html/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor-&gt;dispatch(Object(Magento\Framework\App\Request\Http))
#6 /var/www/myhost.com/public_html/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http-&gt;launch()
#7 /var/www/myhost.com/public_html/index.php(39): Magento\Framework\App\Bootstrap-&gt;run(Object(Magento\Framework\App\Http))
#8 {main}</trace>

please any help


The Authorization token is NOT place on the parameter. Should be set on header instead. Here is an example on POSTMAN:

enter image description here

On cURL, it will be:

curl -X GET --header "Accept: application/json" --header "Authorization: Bearer XXXXXXXXXX" "http://yoursite.com/rest/V1/products/:sku"
  • Thanks for your reply, already I tried it on headers or as parameters in url and works perfectly for some api like products as you did and categories, but for some APIs like V1/customers/me, I got the error. Even if i run the curl on terminal, it works perfectly. I use postman and http requester for firefox. – Jsparo30 Dec 14 '16 at 7:52
  • No problems on my testing site. Did you have a space between "Bearer" and the token? And maybe your token is expired, try to get a new one – PY Yick Dec 14 '16 at 7:57
  • HHH, What is a joke !! there was no space and worked fine in products and categories as I mentioned, but when removed it in customers/me worked fine. Please edit the answer and add the part of remove space to give it the true answer. Thanks. – Jsparo30 Dec 14 '16 at 9:58
  • Actually it's more likely to be token expired. I use the old token to access the API, it shows the same error you stated on question. Just renew the token and the problem solved. – PY Yick Dec 15 '16 at 3:20
  • @Jsparo30 did you found the solution i am also facing same issue – Janarthanan Ramu Sep 28 '18 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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