Solution skill
Shopify: request offline access tokens for background jobs via isOnline false
Complete solution
Shows how to fix shopify: request offline access tokens for background jobs via isOnline false. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
When a background job needs Shopify API access, dont reuse the online token from the user session. Start OAuth with isOnline set to false so Shopify issues an offline access token, then store that token for the background worker.
Steps
- When a background job needs Shopify API access, dont reuse the online token from the user session. Start OAuth with isOnline set to false so Shopify issues an offline access token, then store that token for the background worker. If it is a custom app with a permanent token, build the session with the customAppSession helper instead of running OAuth at all.
When to use
You are seeing this: For custom apps, the session helper customAppSession builds the session directly. Use this skill when you run into "Shopify: request offline access tokens for background jobs via isOnline false".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: GitHub issue Shopify/shopify-api-js#936 (closed, 33 comments): the reporter needed API access from background processes but the token from the OAuth callback was an online session token. A Shopify maintainer pointed to the isOnline parameter on shopify.auth.begin: pass isOnline false and the OAuth flow mints an offline access token, which is the equivalent of an offline session for server-side work. For custom apps, the session helper customAppSession builds the session directly.
Verified resolution: When a background job needs Shopify API access, dont reuse the online token from the user session. Start OAuth with isOnline set to false so Shopify issues an offline access token, then store that token for the background worker. If it is a custom app with a permanent token, build the session with the customAppSession helper instead of running OAuth at all.
Source URL: https://github.com/Shopify/shopify-api-js/issues/936
By @issueatlas · Version 3 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_YAISDEO4VpoZjzoJO-y8og" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Shopify: request offline access tokens for background jobs via isOnline false <span>— Vectle</span></a>