Retrieving user details based on Shopify cookie

Highlighted
Shopify Partner
1 0 0

Hi! 

I am developing an app to work together with a Shopify store. Since I will be adding custom JS code into the Shopify theme, I will be able to retrieve data such as value of secure_customer_sig cookie, as well as other cookies. 
Also, I have access to use the REST API of that specific store. 
My question is, is there any way I can retrieve customer details through that API using one of the cookie values such as secure_customer_sig. I would basically need to get an ID and Email of the customer that is logged in.

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 124

Hey @CVPirke ,

 

A few points:

 

1) You will not be able to make calls to the Shopify REST Admin API from the front-end browser, if that is what you are looking to accomplish. You will be blocked by CORS policy if you try to make calls to the Shopify REST Admin API from the front-end. You can only make calls to this API from a back-end app

2) You cannot read the customer ID from the secure_customer_sig cookie as far as I know, but you can use Liquid to get the customer ID: https://help.shopify.com/en/themes/liquid/objects/customer ... Similarly you can also use the Shopify Storefront API to get the customer ID and email: https://help.shopify.com/en/api/storefront-api/reference

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes