10

I have installed magento2.4.4 and php8.1 and when trying to access rest api using bearer token it is giving error for all the routes.

 {
    "message": "The consumer isn't authorized to access %resources.",
    "parameters": {
        "resources": "Magento_Catalog::products"
    }
}
2
  • Can you update the question with the full API call please?
    – Joao71
    Commented Apr 26, 2022 at 14:47
  • its for all routes
    – M2 Dev
    Commented Apr 26, 2022 at 14:52

4 Answers 4

30

In magento2.4.4 we have to make configuration like this to work rest api with integration token

Congiuration Image

4
  • 1
    This is only valid for integration tokens, not for bearer tokens that are created via the admin user.
    – torhoehn
    Commented May 3, 2022 at 14:32
  • mahn..i have been digging this all through..thanks for the help Commented Nov 7, 2022 at 11:22
  • @torhoehn but it does work for admin generated token too
    – xpoback
    Commented Nov 22, 2022 at 10:20
  • Hello. I don't even have that select box in my dashboard. Any ideas ?
    – noiseymur
    Commented Feb 7, 2023 at 9:57
4

Thanks for above solutions. I also encountered this smiliar issue after upgrade magento from 2.4.1 to 2.4.4-p2. My customized rest API can not work and get the same error. enter image description here

I debug the codes and found there is a configuration to control this logic. I set the "Allow OAuth Access Tokens to be used as standalone Bearer tokens" to be Yes and it works.

enter image description here enter image description here enter image description here

1
  • 2
    Thanks for the information, i faced the same issue and i have updated the configuration which you mentioned above it works for me!
    – Rik Patel
    Commented Jan 5, 2023 at 7:41
1

Is the token still valid? Maybe it is expired, in that case you should call

{{host}}/rest/V1/integration/admin/token

to get a new one. Then you can use it as the authentication token.
If the above call for example give you this as reponse

"z2hmps0r5bp72r1y8rvx7d25wy1odrcu"

In your further calls you must add a header like this

Authorization: Bearer z2hmps0r5bp72r1y8rvx7d25wy1odrcu

Let me know if it helps.

2
  • what could be the issue when it is not working from integration token?
    – M2 Dev
    Commented Apr 27, 2022 at 7:26
  • have you tried to call different REST or use a different user? Can you try with an admin user? Commented Apr 27, 2022 at 7:58
0

Ok. My bet is that there is something wrong whit the APi user profile. First let's go to your admin panel and check wich role is assigned to your API User in Settings => Permissions => All Users.

Now lets go to Settings => Permissions => user roles and check wich resources are accessible by the user

enter image description here

If this solved your issue please don't forget to upvote/ mark as answered.

1
  • All settings seems OK
    – M2 Dev
    Commented Apr 26, 2022 at 17:13

Your Answer

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

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