Shopify Expiring Token Migration Kit (Python)
Shopify is retiring non-expiring offline access tokens for public apps. Shopify's changelog sets two dates. From 1 January 2027, non-compliant public apps are delisted from the App Store and blocked from new installs. From 1 April 2027, Admin API calls with a non-expiring token get HTTP 403. Expiring tokens last 1 hour, and every refresh returns a new refresh token. So your app now needs refresh logic that stays safe when many workers run at once, plus a one-way migration for every existing shop.
The official Remix/Node template does this for you. If your app runs on Python, Celery/RQ workers or a custom stack, this kit covers the parts developers keep getting wrong:
- shopify_tokens/: a small Python package that uses only the standard library.
- get_access_token(shop) refreshes under a per-shop lock and checks again before refreshing. If 10 workers hit an expired token, Shopify sees 1 refresh, not 10.
- call_with_retry retries once after a 401. When several workers get a 401 at the same time, they still trigger only one refresh (this is tested).
- Comes with a SQLite store and a Postgres store.
- migrate.py: a command-line tool with audit, run and verify.
- Supports a dry run, rate limiting and batches.
- Saves each new token before doing anything else.
- Can resume after you stop it.
- Writes a CSV log of every shop.
- Puts each failure in a clear group, such as needs reinstall, locked, or retry within 7 days.
- A rollout order to follow before you run anything, plus CHECKLIST.md, and PORTING.md for Node, PHP and Ruby.
- 32 pytest tests against a fake Shopify endpoint. They need no network.
The requests match Shopify's official shopify-api-ruby source and the shopify.dev guide as of 4 December 2026. Secrets come only from environment variables, and tokens are masked everywhere.
Honest limits:
- Migration can't be undone for a shop, so back up and test on a development store first.
- Check the dates and endpoints on shopify.dev before running in production.
- It can't recover tokens Shopify has already invalidated.
- It handles offline tokens only, not online (per-user) tokens.
- Not affiliated with or endorsed by Shopify.
MIT licensed. Instant download. By Saggurthi Labs.