Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

How to call Shopify API from a webhook?

How to call Shopify API from a webhook?

Thresher
Shopify Partner
20 2 24

Hi there! I've been following the webhook tutorial from the Shopify Node + React guide. I've been able to successfully register, validate, and receive webhooks.  However, my app needs to call the Shopify API after receiving a webhook, and I'm wondering the best way to do this. From what I understand, it's not possible to get an access token from a webhook since those are only provided via OAuth.

 

I came across this post from 2 years ago which suggests storing the Shop URL and access code in a database, then I can retrieve the access code for a given shop using the x-shopify-shop-domain header from the webhook request.

 

Is this the best way to proceed? If possible I'd prefer to avoid using a database since my app otherwise doesn't need it.

Replies 2 (2)

Zameer
Shopify Staff
297 31 90

Hey Thresher,

 

Storing Access Tokens is definitely required for most apps, and a database is one of the recommended methods for storing that information.

 

If you're not storing the Access Token for each shop upon installation, you will then be unable to make any authenticated API calls to that shop in the future. In this case, the merchant would need to uninstall and reinstall your app to generate a new Access Token which you would then need to store for your API calls.

To learn more visit the Shopify Help Center or the Community Blog.

ali46456
Shopify Partner
1 0 0

hay i desperately need it im working on it since 25 days only requirement is i need to get access token and shop name when someone will install my app and post it to another link i have no idea how to do it can u help me with it?