Does your public Shopify app have to move to expiring offline access tokens? Yes, if it calls the Admin API, and by January 1, 2027. On that day, an app that still sends non-expiring offline tokens is delisted from the Shopify App Store and blocked from new installs, and from April 1, 2027 its Admin API requests return 403. You migrate the stores that already installed your app in code, by exchanging each stored token, without asking merchants to reinstall.
In short. Request expiring tokens for every new install, then exchange each non-expiring token you have stored for an expiring pair. From then on, refresh one store at a time and save each new pair in a single write. You are done when the Dev Dashboard Logs show no request made with an “Offline, non-expiring” token.
What changes, and when
Shopify is retiring offline tokens that never expire for public apps, in three steps that start on January 1, 2027. The requirement covers GraphQL and REST Admin API requests. Those dates do not apply to custom apps, apps created by merchants, online access tokens or Payments Apps API requests, but custom and merchant-created apps created from December 1, 2026 must use expiring tokens from the start.
The May announcement said apps would get authentication errors from January 1. The October 27 update replaced that with the three dates above, so existing installs keep working until April 1. Shopify is clear that this is not a grace period:
January 1 is the migration deadline: The later dates give merchants time to prepare, and should not be treated as extra time to migrate.
What Shopify measures is the token your app presents on Admin API requests. Holding an unused non-expiring token does not make an app non-compliant, while sending one from a forgotten job does. The Dev Dashboard raises a Deprecated offline token alert when your app has made such a request in the past 14 days. The emails Shopify sends count every non-expiring token still active, including ones your app no longer uses, and Shopify said on November 2 that some of those counts were too high.
How do expiring offline access tokens work?
An expiring offline access token lasts 1 hour and comes with a refresh token that lasts 90 days. Your app uses the refresh token to get a new pair before the access token runs out, with no merchant involved.
expires_in is 3600)refresh_token_expires_in is 7776000), replaced on every refreshexpiring is left out or set to 0expiring=1 on token exchange or the authorization code grantA refresh is a POST to https://{shop}.myshopify.com/admin/oauth/access_token with grant_type=refresh_token, the refresh token and your client credentials. Each refresh returns a new access token and a new refresh token with a fresh 90 days. The previous access token keeps working until its own hour ends, so requests already in flight finish.
The refresh token you presented is not invalidated at once. It stays usable until the first of these:
- your app uses the newer refresh token,
- your app acquires a new token through token exchange or the authorization code grant,
- 30 days pass since its first use,
- its original 90 days end.
When a refresh token can no longer be used, Shopify answers 401 with {"error": "invalid_request"} and the description “This request requires an active refresh_token”. It sends the same answer for a replaced, expired or unknown token and for an uninstalled app, so your code cannot tell them apart and should not try. Network errors, timeouts, 429 and 5xx answers are different, and safe to retry with the same refresh token.

A store nobody uses does not need a refresh every hour. Refresh when there is work to do, and at least once before the 90 days end, so the store keeps working without the merchant opening your app.
Moving existing stores without a reinstall
Your server exchanges each stored non-expiring token for an expiring pair, using the token itself and your client credentials, with no merchant session. Shopify documents three ways to stop sending non-expiring tokens, and the first two work together.
expiring=1 to the token requests your app already makes, and store the refresh token.A store moves the next time your app gets a new token for it. Stores nobody opens never move.Make the option 1 change first, so that tokens your app gets later expire too, then run option 2 for the stores already installed. Option 1 alone is risky in the React Router template, as the next section shows. The exchange is the request below. Both requested_token_type and expiring=1 are required.
curl -X POST https://{shop}.myshopify.com/admin/oauth/access_token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=urn:ietf:params:oauth:grant-type:token-exchange' \
-d 'client_id={client_id}' \
-d 'client_secret={client_secret}' \
-d 'subject_token={non_expiring_offline_token}' \
-d 'subject_token_type=urn:shopify:params:oauth:token-type:offline-access-token' \
-d 'requested_token_type=urn:shopify:params:oauth:token-type:offline-access-token' \
-d 'expiring=1'The exchange permanently invalidates the old token for Admin API requests, so the new pair must be saved before anything else. If the response never reaches you, repeating the same request with the original token within 7 days returns the same pair. That recovery ends early once you refresh the pair or a later token acquisition replaces it.
invalid_subject_tokenThe token is not an active non-expiring offline token of this app: already migrated, expiring, online or scope-restricted. Check the row by hand.Run it as a batch you can stop and start again. Shopify’s staff advise exchanging a small cohort first and checking real API calls and background jobs before you go further. The script below takes the offline sessions that have neither an expiry nor a refresh token, exchanges them one store at a time, retries what is transient and saves each pair only if the row still holds the token it exchanged. Shopify does not publish a rate for this endpoint, so start one store at a time and add concurrency only once the logs stay clean.
// One store to rehearse: npx tsx scripts/migrate-offline-tokens.ts your-dev-store.myshopify.com
// Then 10 more stores: npx tsx scripts/migrate-offline-tokens.ts 10
// Then the rest: npx tsx scripts/migrate-offline-tokens.ts all
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
type TokenPair = {
access_token: string;
expires_in: number;
refresh_token: string;
refresh_token_expires_in: number;
scope: string;
};
function log(shop: string, outcome: string, status?: number, requestId?: string | null, detail?: string) {
// Never log a token.
console.log(JSON.stringify({ shop, outcome, status, requestId, detail }));
}
function exchange(shop: string, legacyToken: string) {
return fetch(`https://${shop}/admin/oauth/access_token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json" },
body: new URLSearchParams({
grant_type: "urn:ietf:params:oauth:grant-type:token-exchange",
client_id: process.env.SHOPIFY_API_KEY!,
client_secret: process.env.SHOPIFY_API_SECRET!,
subject_token: legacyToken,
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: "1",
}),
signal: AbortSignal.timeout(15_000),
});
}
async function migrate(session: { id: string; shop: string; accessToken: string }) {
for (let attempt = 1; attempt <= 5; attempt++) {
let response: Response;
try {
response = await exchange(session.shop, session.accessToken);
} catch {
await sleep(2 ** attempt * 1000); // Timeout or network error: repeat the same request.
continue;
}
const requestId = response.headers.get("x-request-id");
if (response.ok) {
let pair: TokenPair;
try {
pair = (await response.json()) as TokenPair;
} catch {
// The body was lost after Shopify issued the pair: the same request returns it again.
await sleep(2 ** attempt * 1000);
continue;
}
const now = Date.now();
// One write for the whole pair, and only if the row still holds the token we exchanged.
const { count } = await prisma.session.updateMany({
where: { id: session.id, accessToken: session.accessToken },
data: {
accessToken: pair.access_token,
expires: new Date(now + pair.expires_in * 1000),
refreshToken: pair.refresh_token,
refreshTokenExpires: new Date(now + pair.refresh_token_expires_in * 1000),
scope: pair.scope,
},
});
log(session.shop, count ? "migrated" : "row changed during the exchange, check it", response.status, requestId);
return count > 0;
}
if (response.status === 429 || response.status >= 500) {
log(session.shop, "retrying", response.status, requestId);
await sleep(2 ** attempt * 1000);
continue;
}
// 400 invalid_subject_token, or 403, 404 or 423 for a store Shopify made unavailable.
return log(session.shop, "not migrated", response.status, requestId, (await response.text()).slice(0, 200));
}
log(session.shop, "still failing after 5 tries, run the script again later");
}
const arg = process.argv[2];
const oneShop = arg?.endsWith(".myshopify.com") ? arg : undefined;
const limit = oneShop || arg === "all" ? Infinity : Number(arg);
if (limit !== Infinity && !(Number.isSafeInteger(limit) && limit > 0)) {
throw new Error("Pass a store's myshopify domain, a number of stores to migrate, or all.");
}
const legacy = await prisma.session.findMany({
where: { isOnline: false, expires: null, refreshToken: null, ...(oneShop ? { shop: oneShop } : {}) },
select: { id: true, shop: true, accessToken: true },
orderBy: { shop: "asc" },
});
let migrated = 0;
for (const session of legacy) {
if (migrated >= limit) break;
// One store at a time. Stores that can't migrate stay in the list but don't count, so the next run moves on.
if (await migrate(session)) migrated++;
}
await prisma.$disconnect();The exchange retires any other refresh token for the store, so a token your app acquires while the script runs (a reinstall, or a merchant opening the app) can be retired by the migration while the row check refuses to save the migration’s pair. A lock shared with your refresh workers does not stop that, because the template’s own token exchange never takes it. Run the batch when merchants are least likely to open the app, and refresh once every store the script logs as changed: a 401 means the migration retired its pair, and the merchant’s next visit, or application-only access, gets a new token.

Option 3 is a different route. Application-only access tokens come from the client credentials grant with a JWT your server signs with its own private key, whose public key you add in the Dev Dashboard. Each token lasts up to an hour, with no refresh token, and several can be valid at once. It suits apps that would rather not store and rotate a refresh token for each store, and it is also how you get a store back after losing its refresh token, without waiting for the merchant.
Expiring tokens in Shopify’s React Router template
In @shopify/shopify-app-react-router, one future flag turns on expiring offline tokens, and the Prisma session table needs two more columns to hold them. Newly scaffolded apps already have both.
const shopify = shopifyApp({
// ...
sessionStorage: new PrismaSessionStorage(prisma),
future: {
expiringOfflineAccessTokens: true,
},
});model Session {
id String @id
shop String
state String
isOnline Boolean @default(false)
scope String?
expires DateTime?
accessToken String
// ...the other columns of the template...
refreshToken String?
refreshTokenExpires DateTime?
}Shopify added refreshToken and refreshTokenExpires to the template in December 2025 by editing its first migration. A migration that has already run never runs again, so an app scaffolded before then has neither column in its database. Add the two fields to the schema, create a migration with npx prisma migrate dev --name session_refresh_token and deploy it before the flag. Without the columns, the app cannot save an expiring session.
After the change, the offline row (offline_{shop}) holds an access token whose expires is an hour away, a refresh token, and a refreshTokenExpires 90 days out. In webhooks, Flow, app proxy, fulfillment service and unauthenticated contexts, the library refreshes it when it has expired or expires within the next 5 minutes, and saves the new pair to the same row. A page of your app loading in the admin never refreshes: when the session has expired, authenticate.admin runs token exchange instead, which is what Shopify’s docs ask for while a merchant session is active.
The flag does not touch the stores you already have. A session stored without an expiry date never counts as expired, so authenticate.admin keeps using its non-expiring token and never exchanges it. Shopify’s staff confirm that changing the configuration “does not convert credentials already stored in your database”.

Background jobs and webhooks
Code that runs without a merchant must ask the library for an admin context instead of reading the token from the database. A token read straight from the Session table lives an hour at most, and is usually expired by the time a nightly job uses it.
unauthenticated.admin(shop) loads the offline session, refreshes it when needed and returns a GraphQL client. authenticate.webhook, authenticate.flow, the fulfillment service and app proxy contexts do the same. None of them takes a lock, though: two jobs for the same store that start together both see an expired token and both refresh it.

Within one process, share one call per store:
import { unauthenticated } from "./shopify.server";
type AdminContext = Awaited<ReturnType<typeof unauthenticated.admin>>;
const pending = new Map<string, Promise<AdminContext>>();
// Every caller in this process shares one load, and at most one refresh, per store.
export function adminForShop(shop: string): Promise<AdminContext> {
let context = pending.get(shop);
if (!context) {
context = unauthenticated.admin(shop).finally(() => pending.delete(shop));
pending.set(shop, context);
}
return context;
}
// In a job:
const { admin } = await adminForShop(shop);
const response = await admin.graphql(`#graphql
query { shop { name } }`);Across several workers or instances, wrap the same call in a lock all of them share, such as GET_LOCK in MySQL, an advisory lock in PostgreSQL or a key set with NX in Redis. The second worker then reads the row the first one saved, finds a valid token and does not refresh. The library’s own paths do not take your lock, though. When a merchant opens the app as a job refreshes, the page’s token exchange retires every other refresh token for the store, so one of the two pairs is dead on arrival. Shopify’s docs say not to acquire and refresh at the same time for the same store. Services that need tokens on their own schedule are a good fit for application-only access, whose tokens never replace each other.
Webhooks need one more change. With the flag on, authenticate.webhook refreshes the store’s token before your handler runs. When a store uninstalls, its tokens are revoked, so for any store idle for more than an hour that refresh fails. Up to version 4.0.2 the library then answered 500 instead of calling your handler, and app/uninstalled and the compliance topics failed on every retry. Version 4.0.3, released on November 12, 2026, calls your handler without a session instead, so upgrade to it or later.
The template’s app/uninstalled route deletes the sessions only inside if (session), so once a session can be missing it must delete them by store. The compliance routes must likewise do their work before they answer 200. Deleting by store has one catch, as in the template: an app/uninstalled retry that arrives after a quick reinstall also deletes the new install’s session. The merchant’s next visit runs token exchange again, but background jobs for that store fail until then.
import type { ActionFunctionArgs } from "react-router";
import { authenticate } from "../shopify.server";
import db from "../db.server";
export const action = async ({ request }: ActionFunctionArgs) => {
const { shop } = await authenticate.webhook(request);
// From 4.0.3 the session is missing when the refresh failed, so delete by store.
// Deleting nothing is fine on a retry.
await db.session.deleteMany({ where: { shop } });
return new Response();
};Races, lost responses and other edge cases
Overlapping refreshes and responses that never arrive are what break token renewal most visibly. The table covers what each case does and the fix.
The lost-response case is the one the August 28 change fixed. In June, a developer reported two 520 errors on refresh requests, after which every retry with the stored refresh token returned 401 and the merchant was locked out for about two hours. Shopify first added a short retry window, then the rule that a refresh token stays usable until you use its replacement. It does not bring back a refresh token that later refreshes or a new token acquisition have already retired, so a backup restored from days ago, or a chain that two workers keep rotating at the same time, can still end in a 401.
Developers also reported refresh tokens that came back expiring about a second after they were issued, instead of 90 days later. The developer who reported it says Shopify’s support confirmed a fix at the end of July. Read refresh_token_expires_in from every response rather than assuming 90 days, and alert when it is far shorter.
A migration checklist
The list follows the order that keeps every store working during the change. Copy it into your issue tracker and tick each line off.
- [ ] Find every place that reads an offline token: routes, jobs, queues, webhooks, scripts, other services
- [ ] Add refreshToken and refreshTokenExpires to the Session table, with a migration
- [ ] Update @shopify/shopify-app-react-router (4.0.3 or later), @shopify/shopify-api and the Prisma session storage
- [ ] Replace every direct read of session.accessToken with unauthenticated.admin(shop)
- [ ] Serialize refreshes per store: one process, then every worker and instance
- [ ] Delete sessions by store in app/uninstalled, since the session can be missing
- [ ] Deploy those changes, then turn on future.expiringOfflineAccessTokens and deploy
- [ ] Log every token request: shop, grant, status, Shopify error, x-request-id, never the token
- [ ] Exchange the stored non-expiring tokens on a dev store, then on a few stores, then on all
- [ ] Skip stores answering 403, 404 or 423, and check every 400 by hand
- [ ] Schedule a refresh for stores whose refresh token expires within a few weeks
- [ ] Filter the Dev Dashboard Logs by token type until "Offline, non-expiring" is empty
- [ ] Watch the Deprecated offline token alert clear, 14 days after the last old request
- [ ] Turn on Admin API token expiry in the Dev Dashboard to confirm nothing breaksHow to test the migration on a dev store
Install the current version of your app on a dev store first, so the store holds a non-expiring token like your real installs, then reproduce each failure on purpose.
- Check the offline row:
expiresandrefreshTokenare empty. - Deploy the flag and the new columns, then open the app. The row does not change, which shows why the migration script is needed.
- Run the script with the dev store’s myshopify domain, so it exchanges that store only. The row now has an
expiresan hour away and arefreshTokenExpires90 days out, and an Admin API call through the app works. - Force an expiry by setting
expiresto a minute ago in the database, then run a background job. The row gets a new pair, and your logs show one refresh. - Force an expiry again and start two jobs for the store at the same moment. Your logs should still show one refresh.
- Refresh once by hand with the stored refresh token and do not save the answer. The app’s next refresh, with the same token, must still succeed.
- Force an expiry, then uninstall the app.
app/uninstalledmust answer 2xx and delete the store’s sessions. - In the Dev Dashboard Logs, set Type to GraphQL request and Token type to “Offline, non-expiring”, with a time range that starts after the migration. Use the app and run a job, then check that nothing appears for the dev store. Repeat with REST request if your app uses REST.
- Turn on Admin API token expiry in the app’s Settings in the Dev Dashboard. From then on, every store rejects Admin API requests that use a non-expiring token, within about 30 minutes. Run your jobs and webhooks again and watch for rejected requests. The setting migrates nothing and you can turn it off, but it applies to every store with the app installed, so try it once your real installs are migrated.
What to monitor once you’ve switched
Watch the Dev Dashboard for leftover non-expiring requests, and your own logs for refreshes that fail. The first tells you whether Shopify sees you as migrated, and the second whether stores are about to lose access.
- The Deprecated offline token alert clears 14 days after your app’s last request with a non-expiring token. If it stays, filter the Logs by token type to find the requests. Logs keep 30 days, a search covers at most 7, and a wide range can show a sample.
- Count refresh answers by status. Each 401
invalid_requestis a store that needs a new token, while a run of 5xx is a Shopify incident to retry through, as on October 29, 2026, when token requests returned 504 for a while. - Look for any 403 whose message contains “Non-expiring access tokens are no longer accepted”. A missing access scope also returns 403, so match on that phrase.
- Track stores whose
refreshTokenExpiresis getting close, and the 2xx rate ofapp/uninstalledand the compliance webhooks.
Log each token request with the store, the grant type, the status, Shopify’s error code, the new expiry times and the x-request-id header, which Shopify needs to look into a failed request. Never log the tokens themselves.
For apps that bill through Meridian. To create a Shopify subscription for a store, Meridian’s Plan Builder reads that store’s offline access token from your app’s own session table, the one this migration changes. The hosting docs explain how.
Sources: Shopify’s pages on access tokens, migrating to expiring offline access tokens, refreshing an expiring offline token, application-only access tokens and monitoring and logs, the October 27 and November 19 changelog entries, the staff Token Expiry FAQ in the developer community, and the source code of @shopify/shopify-app-react-router 4.0.4. All checked on November 19, 2026. For how Shopify delivers the webhooks above, see the guide to Shopify webhooks.



