Storefront API with embedded custom app not working

Storefront API with embedded custom app not working

Shaf1
Shopify Partner
2 0 0

The context:

I am building a Shopify Custom App (NOT created in Shopify admin). I created the app with the Shopify CLI. This app allows the admin in the backend to pick some products that must be shown in a pop-up in the store.  I save the gids of the product in an external database and retrieve them in the store.  The product picking in the back-end already works. Now to the problem.

 

The problem

My problem is that I can't use the Storefront API because I have to pass an X-Shopify-Storefront-Access-Token which isn't provided for custom embedded apps. According to the docs I could create a storefront Accesstoken but when I try to use graphql app for performing the graphql query to get a new X-Shopify-Storefront-Access-Token. The script I load into the storefront is a JS file I host in the 'public' folder of the app I am building. I insert this into the storefront using script-tags. Is there a better way to insert code into the storefront where I can use the Storefront API? If so, how? Or am I doing something incorrect right now?

Replies 0 (0)