0

I am following a Magento tutorial and I get stuck at this step https://devdocs.magento.com/guides/v2.4/rest/tutorials/orders/order-create-quote.html So I managed to create user, but I cannot make a shoppingcart. I have requested the bearer token and pass it to /rest/all/V1/carts/mine/ But all I get back is:

{
    "message": "The consumer isn't authorized to access %resources.",
    "parameters": {
        "resources": "self"
    }
}

I am able to create a user by passing the admin bearer token, but that is not ideal for me. The easiest way for me seems that the user can create a shoppingcart with it's own credentials.

So is there a setting I can change? I am aware of the Allow Anonymous Guest Access setting, but since I made an export of my config I cannot edit this value. So is there a way to edit that value throught the config.php?

1 Answer 1

1

First Login in Magento2 Using Api

Api Url : https://xyz/rest/V1/integration/customer/token
Token : dcx8leo2oquwv6wjmkpxsl3nnzg2n5s0(#BEARER_TOKEN)
Method : Post
Body : { "username": "[email protected]", "password": "Test@123456789" }
Response: "82ag2sdf7jay1ofsja0iskk59joaas28"(#CUSTOMER_ACCESS_TOKEN)

Note : With login API we will get Customer Token for ex. 82ag2sdf7jay1ofsja0iskk59joaas28 and this will be pass in the next API.

-----------------------------------------------------------------------

Api Url : https://xyz/rest/V1/carts/mine/
Token : 82ag2sdf7jay1ofsja0iskk59joaas28(#CUSTOMER_ACCESS_TOKEN)(Previous Api Reponse)

Now you will get proper response.

3
  • These are the exact steps I did in the link I attached in my questions. Still getting the same error message Commented Apr 25, 2022 at 12:33
  • Api url is wrong correct is : xyz/rest/V1/carts/mine Commented Apr 26, 2022 at 5:24
  • That was it, I was requesting it with the /all/ path parameter to specify the store. Just out of curiosity do you know where I need to specify the store parameter? Commented Apr 26, 2022 at 9:48

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.