How to correctly update webhooks in Remix app?

How to correctly update webhooks in Remix app?

AlexanderKushch
Shopify Partner
3 0 0

Using the '@shopify/shopify-app-remix' template to develop an embedded app.
Facing a problem with the webhook registration flow. When I add new webhooks in the production build, the app does not update the list without reinstallation.
Previously, when I tried to fix this problem, I added a call to the 'shopify.registerWebhook({ session })' function in the ' $.tsx' loader with the intention of registering webhooks again without reinstalling. However, the next day, I started encountering the error below:

2024-02-27T15:05:02.710600+00:00 app[web.1]: HttpResponseError: Received an error response (401 Unauthorized) from Shopify:
2024-02-27T15:05:02.710706+00:00 app[web.1]: "[API] Invalid API key or access token (unrecognized login or wrong password)"
2024-02-27T15:05:02.710706+00:00 app[web.1]: If you report this error, please include this id: 7a131cc7-30b7-4593-9875-d7c0fd12d190


It appears that I cannot call 'shopify.registerWebhook' outside of the 'afterAuth' hook.
I would like to know the correct flow for updating webhooks.

Replies 0 (0)