I am creating an app which is embedded into Shopify Admin. When the app starts up, I want to read the user's email address, and check whether that email address exists already in my own database. The documentation on the App Bridge makes it seem as though this is possible, but:
- I am using the package @Shopify/app-bridge-react, which seems inconsistent with this documentation. Perhaps this is not fully-featured?
- Even when using App Bridge as a CDN resource, the console logged user object in the snippet below, always has undefined for user.email (in fact all properties are undefined or empty apart from accountAccess), despite the fact I am logged into admin.shopify.com.
The second part of this problem is that I would like to store some metafield about the relationship between the Shopify user and my own database on Shopify's backend. I can't see that it is possible to store a metafield on the user in this way, however. Is there a different approach I can take, or am I missing something here?
The app-bridge API returns the admin user email when running within the Shopify POS app.
If your app is running in a browser or in the Shopify Mobile app the user object only contains accountAccess (which is set to "Account owner", "Full access", or "Limited access").
You can get the numeric Shopify user id (not email) on your server via the session token (JWT).
Extract the sub value from the payload. This is the ID of the user that made the request.
Dive into the world of Print-on-Demand and discover how it can transform your online busin...By Imogen Feb 19, 2024
Discover how to transform your online store into a delightful shopping destination. Learn ...By Ollie Feb 13, 2024