cancel
Showing results for 
Search instead for 
Did you mean: 

magento "act as customer" via admin token on rest interface

magento "act as customer" via admin token on rest interface

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?

3 REPLIES 3

Re: magento "act as customer" via admin token on rest interface

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!

Re: magento "act as customer" via admin token on rest interface

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 tokenPOST /V1/integration/customer/tokenintegrationCustomerTokenServiceV1

 

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 tokenPOST /V1/integration/admin/tokenintegrationAdminTokenServiceV1
Suman Kar(suman.jis@gmail.com) Magento Certified Developer Plus Skype: sumanphptech Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.

Re: magento "act as customer" via admin token on rest interface

@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.