I want to access customer level apis, like /V1/carts/{cartId}/items, but I only have an admin token, and the customer id. Is there some way to say, with my admin token, I want to do this api call as if I was customer 12345?
HI @carlo_kok
You need cart id instead of customer id if you using admin token.
More info:
https://devdocs.magento.com/swagger/index_22.html#/quoteCartRepositoryV1/quoteCartRepositoryV1GetGet
I hope it will help you!
There are 3 approaches for accessing Magento API. Considering your problem I would say Approach 1 will be the best possible solution as you are using integration token not exploiting customer or admin user name and password.
Approach 1 :
Create an integration token from the Magento Admin Panel. Give proper access, then use integration token for your all API call
https://devdocs.magento.com/guides/v2.3/get-started/authentication/gs-authentication-token.html
Approach 2:
If you have customer user name and password, then first create a custom token and use that token in your API call
Get customer token | POST /V1/integration/customer/token | integrationCustomerTokenServiceV1 |
Approach 3:
If you have Admin user name and password the, create an admin token and use that token in your API call
Get admin token | POST /V1/integration/admin/token | integrationAdminTokenServiceV1 |
@Suman Karyes. I'm using approach 1 and that works fine. My only problem is that as an "integration", a lot of apis either don't let me specify the customerID, or in the case of
https://devdocs.magento.com/swagger/index_22.html#/quoteCartRepositoryV1/quoteCartRepositoryV1GetGet
I can pass a cart id, but that would let 1 customer access the cart of another, as I can't say "only the carts that are for this user" this way, nor does the result give me any way to check if the cart WAS owned by the right customer.