Security
How to move a Shopify app to expiring offline access tokens
Offline tokens now expire after an hour, with a 90-day refresh token. The dates, the exact requests, rotation, migrating old tokens and the errors to handle.
· 8 min read
For years a Shopify app got one offline access token at install and kept it forever. That is ending. Offline tokens now expire after an hour, and the app keeps itself signed in with a refresh token that lasts 90 days and is replaced every time it is used.
The change is small in code and large in consequences: every place that reads a stored token has to go through a function that can refresh it, two workers must never refresh the same store at once, and a token pair that isn't saved can lock you out of a store. This guide covers the dates, the exact requests, how rotation behaves, how to migrate the tokens you already hold, and the errors worth handling.
What changed, and when
Shopify's dates for apps that call the GraphQL or REST Admin API:
| Date | What happens |
|---|---|
| April 1, 2026 | New public apps must use expiring offline tokens. |
| December 1, 2026 | New custom apps and merchant-created apps must use them from the start. Ones created before that date keep their existing tokens. |
| January 1, 2027 | Public apps still using non-expiring tokens are delisted from the App Store and blocked from new installs. Existing installs keep working. |
| January 15, 2027 | Merchants using such an app see a warning in the Shopify admin. |
| April 1, 2027 | Shopify rejects Admin API requests that present a non-expiring token, and merchants lose access until they re-authenticate. |
Shopify says this timeline does not apply to the Payments Apps API, or to custom and merchant-created apps.
Two other security requirements land in the same months: declaring your storefront's network access and an IP allowlist for the Admin API. The allowlist limits where a token can be used; expiring tokens limit for how long. Every date and requirement is on one page: Shopify app security deadlines 2026–2027.
How long each token lives
| Token | Lifetime |
|---|---|
| Expiring offline access token | 1 hour (expires_in: 3600) |
| Refresh token | 90 days (refresh_token_expires_in: 7776000) |
| Non-expiring offline token (the old kind) | No expiry; valid until uninstall or until the client secret is revoked |
expires_in and refresh_token_expires_in are seconds from now, not dates. Store absolute times (now + expires_in), and use the values Shopify returns rather than hard-coding an hour.
Ask for an expiring token
Every grant goes to the same endpoint:
POST https://{shop}.myshopify.com/admin/oauth/access_tokenThe change is one parameter, expiring=1. With the authorization code grant:
client_id=...&client_secret=...&code=...&expiring=1With token exchange (embedded apps that swap a session ID token for an offline token):
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
subject_token=<the ID token>
subject_token_type=urn:ietf:params:oauth:token-type:id_token
requested_token_type=urn:shopify:params:oauth:token-type:offline-access-token
expiring=1Without expiring=1 (or with expiring=0, the default) you still get the old non-expiring kind. The response for an expiring token carries five fields:
{
"access_token": "shpat_...",
"scope": "write_products,...",
"expires_in": 3600,
"refresh_token": "shprt_...",
"refresh_token_expires_in": 7776000
}If your app is built on one of Shopify's templates, the docs describe a flag instead: future: { expiringOfflineAccessTokens: true } in shopifyApp(), then deploy.
Refresh before it expires
To get a new access token, send the refresh token to the same endpoint:
grant_type=refresh_token&client_id=...&client_secret=...&refresh_token=shprt_...The answer is a new access token and a new refresh token, with a fresh 90 days. The access token you held keeps working until its own expires_in runs out, but use the new one from now on.
The shape most apps end up with is one function that every Admin API call goes through:
function validToken(shop):
row = load token row for shop
if row.expires_at is more than 60 seconds away:
return row.access_token
lock refresh for this shop # one refresh per store at a time
row = load token row for shop again # another worker may have refreshed already
if row.expires_at is more than 60 seconds away:
return row.access_token
answer = POST refresh_token grant
save access_token, refresh_token, both expiry times in ONE write
return answer.access_tokenReplace every direct read of the stored token with that function. The 60 seconds of margin is the one Shopify's own sample uses; the docs also suggest refreshing when a request returns 401.
How rotation really works
It is tempting to think the old refresh token dies the moment you use it. It doesn't.

Shopify keeps the refresh token you presented usable until the earliest of:
- your app uses the newer refresh token (the normal case: the old one is retired at once),
- your app gets a new token through token exchange or the authorization code grant (this retires every other refresh token for that app and store),
- 30 days after that refresh token was first used,
- its original 90-day expiry.
Shopify added this recovery window in August 2026 so that an app which refreshed but failed to save the new pair can retry with the token it still has. Treat it as a safety net, not a reason to keep using old tokens.
The race to avoid
Two things retire each other's results:
- Two workers refreshing the same store at the same time. One of them ends up holding a pair the other has already replaced.
- A token exchange and a refresh for the same store at the same time. Each new token retires the other.
So: serialize refreshes per store (a lock, a queue, or a single worker), and write the access token, refresh token and both expiry times together, in one transaction.
Stores that go quiet
A refresh token lasts 90 days from when it was issued, and each refresh issues a new one. A store where your app does nothing for 90 days loses its refresh token, and the merchant has to open the app again. Shopify's advice for dormant or frozen stores: refresh at least once before the 90 days are up, for example from a scheduled job.
Migrate the tokens you already hold
You don't need every merchant to reinstall. Shopify documents a one-off exchange of an existing non-expiring token for an expiring pair, with no user session:
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
client_id=...&client_secret=...
subject_token=<the stored non-expiring offline token>
subject_token_type=urn:shopify:params:oauth:token-type:offline-access-token
requested_token_type=urn:shopify:params:oauth:token-type:offline-access-token
expiring=1Shopify rejects online, delegate, scope-restricted or already-expiring tokens as the subject. A wrong parameter returns 400 with invalid_subject_token or invalid_requested_token_type.
To find what still uses the old kind, open your app in the Dev Dashboard, go to Logs, filter Type to GraphQL and REST requests, and Token type to "Offline, non-expiring".
The errors to handle
| What you see | What it means | What to do |
|---|---|---|
403 with "Non-expiring access tokens are no longer accepted for the Admin API" | The request used an old non-expiring token | Migrate it, or re-authenticate the store. Match on that phrase: a missing scope is also a 403 |
401 with {"error": "invalid_request"} and "This request requires an active refresh_token" | The refresh token is unknown, already replaced, expired, or the app was uninstalled | Final. Don't retry; re-authenticate through token exchange when the merchant next opens the app |
Network error, timeout, 5xx or 429 on a refresh | Nothing was decided | Safe to retry with the same refresh token |
400 on token exchange | The ID token is invalid or expired (they last about a minute) | Get a fresh ID token and exchange again |
And the basics that make all of this safe: keep refresh tokens in a secrets store or encrypted at rest, never send them to the browser, and alert on refresh failures so you hear about a stuck store before its merchant does.
A use case: what happened in our own app
We moved one of our own apps, a Laravel app that creates orders for merchants, to expiring tokens. What we ran into is common enough to be worth writing down.
- The token request succeeded, and the first API call failed. Our install flow still asked for the old kind of token. The exchange returned
200with a token, and the first Admin API call came back403with the "Non-expiring access tokens are no longer accepted" message. Nothing failed at install, so the logs looked fine until an order was placed. - One function, everywhere. We added the refresh token and both expiry times to the table that holds each store, and a
getValidToken()method that refreshes 60 seconds early. Then we replaced every direct read of the stored token with it, in every controller that calls the Admin API. - Reinstalls update, never duplicate. The install callback now updates the existing row for the store instead of creating one, so a merchant who reinstalls keeps their settings.
- An iframe surprise after OAuth. Our callback used to redirect to the store's admin URL. Inside the embedded admin that becomes
admin.shopify.com, which refuses to load in a frame, and merchants saw "refused to connect" on first open. Redirecting to our own app's URL fixed it.
When you look after several apps, a token problem shows up as a sudden drop in orders or installs, not as an error. Hybrid Workspace puts every Shopify app you ship on one screen, so a store that stops working stands out, and the Shopify app metrics guide shows where to look.
Sources
- Use expiring offline access tokens, Shopify developer documentation
- Access tokens: lifetimes, rotation and grants, Shopify developer documentation
- Migrate to expiring offline access tokens, Shopify developer documentation
- Implement token exchange: refresh an expiring offline token, Shopify developer documentation
- Offline access tokens now support expiry and refresh, Shopify developer changelog, December 10, 2025
- More resilient refreshes for expiring offline access tokens, Shopify developer changelog, August 28, 2026
- Expiring offline access tokens required for new custom apps as of December 1, 2026, Shopify developer changelog, November 19, 2026