Goal
I want to create a following app.
Merchant selects 'top products' for each customer. These will be stored in my backend.
For example:
- Customer A:
- Product X, variant 1
- Product Y, variant 3
- Customer B:
- Product X, variant 2
- Product Z, variant 1
- Product W, variant 1
The customer should then be able to login, go to a page in the store (e.g. store.com/top_products
) and see their own 'top products'.
What I managed to do so far
I managed to deploy the rails Shopify app (https://github.com/Shopify/shopify_app, which uses the shopify_api gem) to Heroku and connect it to my store.
I also managed to setup the app proxy. I get the right response from the app for both the admin app page and the app proxy.
Essentially my public app seems to work fine.
What I have to do now
I will have to call something like this in the app proxy:
ShopifyAPI::Product.find(:all, params: { limit: 10 })
However, this can be only called from ShopifyApp::AuthenticatedController
(like in the admin app controller) and not ShopifyApp::ApplicationController
(like in the proxy controller).
So far I only managed to call the APIs and see the correct results from the admin dashboard of the store.
I cannot manage to call ShopifyAPI::Product.find
from unauthenticated App Proxy.
Google doesn't really help me. This is similar to my problem (has no solution though): https://ecommerce.shopify.com/c/shopify-discussion/t/how-to-connect-to-a-store-with-api-from-app-proxy-request-429417
Question
- What would be the best way to call the API from the App Proxy?
- Or how do I display some information on the store frontend using my backend which talks to the store's API? Is an app proxy the correct approach?