How to authenticate API requests for multiple installed Shopify apps?

Lutty
Shopify Partner
2 0 0

Hello,

I have an application distributed on the shopify app store.

It has been installed on several shops and I would like to be able to make API requests on these shops to, for example, detect new orders and access a metafield of the products included in the order.

To do this, I have two options:

  • Subscribe to the ORDERS_CREATED webhook and connect to the Shopify API admin on the server. But how can I authenticate myself to retrieve data from the shop where the order was placed?

 

  • Create a cronjob that will check each of the shops that have installed my application to see if there are any new orders, and if so, fetch the product metafields. But once again, how do I retrieve the data?

My biggest concern is how to authenticate myself on the API admin without having received a request from a user of my plugin beforehand?

Hopefully my request is clear.

Thanks

Replies 3 (3)

hardik355
Shopify Partner
235 22 35

Hello @Lutty 
Hope you're doing well

Maybe without Shopify scope permission. you are not able to access the order or any other details. I'm not sure if there is another way.

If helpful then please Like and Accept Solution.
For App Development and Design changes Hire Me.
Skype: live:hardikradadiya355
Thanks
Lutty
Shopify Partner
2 0 0

I have the permission.

I have seen that I have the access token of all shop that have installed my plugin in the SQLite database. So I just need to get a new token with the refresh token and I can request for API of all shop.

hardik355
Shopify Partner
235 22 35

If you have scope as required for order webhook, then using the order ID which is received from webhook call the api /admin/api/2023-01/orders/{order_id}/metafields.json and it gives all meta fields.

If helpful then please Like and Accept Solution.
For App Development and Design changes Hire Me.
Skype: live:hardikradadiya355
Thanks