Reputation: 605
Background
I'm building a Shopify embedded app and rely on the app/uninstall webhook to revoke a users access once they uninstall the app. I revoke their access by removing their access token from my db and adding them to an uninstall list.
Issue
The Shopify app/uninstall webhook is firing multiple times and sometimes very randomly (i.e 3am in the morning.) This is causing problems because occasionally if a user reinstalls the app I'll get a random uninstall webhook firing and remove their access.
Question
What is a responsible way to handle Shopify webhooks and their potential randomness/duplication so I can be confident when handling uninstalls?
Upvotes: 1
Views: 840
Reputation: 605
After quite a bit of testing and forum researching I've figured out a good defensive coding strategy to the randomness of Shopify webhooks.
Solution
Code defensively! Don't solely rely on the webhooks to trigger database actions. See below for my defensive coding practice.
Upvotes: 3