How to get customerId when customer logged when using JS buy SDK in a RN app?

Solved
Highlighted
New Member
1 0 0

Hi, I have a requirement. I will implement another database for my own like SQL or others. And I need to combine the Shopify customers. In other words, the user in my database has another role. So here, first I want to use Customer's customerId in Shopify so that I can define who the user is when the customer had logged in. I have done some research in storefront API and Admin API, the timing I can get the customerId is below, 

1. storefront API: customerCreate using GraphQL

2. Admin API: Query all customers using RESTful or GraphQL.

 

I am curious why can't  I get the customerId but no only the customerAccessToken when I using customerAccesssTokenCreate in StoreFront API. Is this for security?

 

So is there a recommended method to get the customer's Id when the customer had logged in? If not, I found the email is the unique Id for Shopify, so can I use this property as a unique Id determining who the user is in my database?

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

This is an accepted solution.

Hi @AllenYang ,

 

If you have the CustomerAccessToken, then you can simply query the `customer` query root by this token and get the Customer ID that way:

query { 
  customer(customerAccessToken:"..."){
    id
  }
}

 

 If not, I found the email is the unique Id for Shopify, so can I use this property as a unique Id determining who the user is in my database?

Yes the e-mail address is unique for all customers in Shopify so you can make that as the unique column/key of your SQL Database

 

 

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

1 Like