How to validate Shopify API requests in Node.js when permissions are updated

I’m building a Node.js application for Shopify and running into an issue with request validation. When the app permissions get modified, I need to figure out how to properly verify if the incoming Shopify requests are still legitimate.

Right now I’m not sure what’s the best approach to handle this scenario. Should I be checking something specific in the request headers or payload? What happens to the existing tokens when scope permissions change?

Has anyone dealt with this before? I want to make sure my app doesn’t accept invalid requests after permission updates. Any guidance on the proper validation method would be really helpful.

I’m pretty new to Shopify development so maybe I’m missing something obvious about how the authentication flow works when scopes get changed.

The validation approach depends on whether you’re dealing with webhook requests or API calls from your app. For webhooks, you need to verify the HMAC signature using your webhook secret - this remains valid even when scopes change since webhooks use a different authentication mechanism than access tokens. However, if you’re making API requests on behalf of the store, those access tokens will indeed become invalid when permissions are updated. I’ve found that implementing a middleware function that catches 401 responses and automatically triggers the reauthorization flow works well. You can also proactively check token validity by making a simple API call to the shop endpoint before processing critical operations. One thing that caught me off guard initially was that Shopify doesn’t notify your app when tokens become invalid due to scope changes. The store owner has to reinstall or reauthorize your app manually, so building robust error handling around authentication failures is essential for a smooth user experience.

When permissions change in your Shopify app, the existing access tokens become invalid and you’ll need to go through the OAuth flow again to get new tokens with the updated scopes. The key thing to understand is that Shopify doesn’t automatically update existing tokens when you modify your app’s permission requirements.

For request validation, you should always verify the HMAC signature in the webhook headers or use the access token to make a test API call to confirm it’s still valid. I learned this the hard way when my app started getting 401 errors after a scope update. The solution was implementing a token validation check that catches these authentication failures and triggers a re-authorization flow.

Your app should gracefully handle these invalid token scenarios by redirecting users back through the OAuth process. This ensures they grant the new permissions and you receive fresh tokens that work with your updated scope requirements.