Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Function gating across clouds

Once data moves from SAP on AWS or Azure to Shopify, Cloudflare and Google Cloud, ERP is no longer the hub. In a single-ERP estate SAP’s batch schedule was the control; spread across clouds, the only shared point is the release gate. Every flow (the Merchant feed, a BigQuery segment, an audience, an agent call) now depends on it being up, current, and the same everywhere. No cloud provider supplies that gate: each has its own functions, identity, logs and residency controls, and the decision falls between them.

 AWS / Azure                  Cloudflare                     Google Cloud / Shopify
 SAP ECC or S/4 (RISE)  ──▶   Workers (edge, consent)  ──▶   BigQuery, Merchant, Ads
 IDoc / RFC / CSV             Xano release gate              Shopify Admin API, Shopify Functions
         └─────────────── every hop asks the gate ───────────────┘

The dependency gaps

GapWhat goes wrongWhat closes it
AvailabilityThe gate is a single point of failure for every exportA failure mode per purpose: fail closed for ads and audiences; order fulfilment (the contract) is never gated
Freshness at the edgeConsent cached at the edge outlives a withdrawal. Cloudflare KV is eventually consistent: a write can take about 60 seconds to reach every locationRevocations read from a strongly consistent store (a Durable Object, or Xano live); cache only grants, with a short expiry
Identity across cloudsAWS IAM, Microsoft Entra, Google Cloud IAM and Shopify app tokens don’t trust each other, so secrets get copied into eachWorkload identity federation and short-lived tokens; no long-lived keys stored per cloud
The rule forksThe same rule is rewritten for Lambda, Azure Functions, Workers, Cloud Functions and Shopify Functions, and the copies driftCompile the rule once. Rust to WebAssembly runs in a Worker and in a Shopify Function, and as a native or Python module elsewhere (see Why 11ty, and when Astro)
Residency in transitBoth ends are in the EU, but a hop is processed in a US region or at a global edgeA route pinned per regime, checked per hop, not only per endpoint; regional processing settings at the edge
Retries and duplicatesA retry between clouds creates a second order, feed item or audience memberAn idempotency key made at the source and carried to every destination
Audit across cloudsEach cloud’s logs show only its own hop; no one can reconstruct a decisionOne correlation ID per decision, a receipt in the Xano ledger for every export, UTC timestamps throughout
Rule versionsA rule changes during a batch, and part of it is exported under the old oneEvery gate rule versioned; the version written on each receipt
EgressEvery hop between clouds is a data-transfer charge, worse with full extractsDeltas, not full tables; one region per regime
OwnershipEach cloud team owns its hop; no one owns the decisionOne owner for the gate and its rules; every platform calls it rather than reimplementing it

What this means for a programme

  • The licence position stays manageable. Porting SAP data out to Shopify, Cloudflare and Google Cloud is mostly reads, which carry little exposure under Digital Access. The gate doesn’t change that; any write back (orders, returns) still counts. See Licensing penalties by flow.
  • The gate is core infrastructure, not a feature. It needs an availability target, a defined failure mode, a release process and an owner, as the ERP had. Most programmes design the data movement and leave the gate for later; that is where they fail.
  • Consent stays where the gaps put it. The gate reads the append-only ledger described in Consent gaps; no cloud on the route holds its own copy of the decision.

The rule: moving SAP data across clouds removes ERP as the hub and makes the release gate the dependency every flow shares. Build it once, run it everywhere (Rust to WebAssembly), read consent from a store that is always current, keep each hop in its regime, and leave one receipt per decision.

Shopify’s 2026–27 token and allowlist deadlines

Shopify is tightening how public apps hold Admin API tokens, which puts two of the gaps above (identity and freshness) on a deadline. Both rules apply to public apps only; custom apps and apps a merchant creates in their own admin are exempt.

RuleWhat it doesDeadline (11:59 PM ET)Without it
IP allowlistLimits the networks an app’s Admin API tokens can be used from; other sources get 403Nov 12, 2026 for apps using bulk operations (bulkOperationRunQuery, bulkOperationRunMutation); Nov 20, 2026 for all other public appsBulk queries and mutations blocked (Nov 12); delisted from the App Store, no new installs, and flagged in the merchant’s Settings > Apps (Nov 20); merchants see a warning in the admin (Jan 15, 2027); Admin API requests fail (Apr 1, 2027). Existing installs keep working until Apr 1, 2027
Expiring offline tokensBackground (“offline”) access tokens last 1 hour and renew through a refresh token: 90 days when issued, replaced with a new one on every refreshJan 1, 2027 (the migration deadline; the later dates are notice for merchants, not extra time)Delisted and blocked from new installs, and flagged in the merchant’s Settings > Apps; existing installs keep working (Jan 1); merchants see a warning in the admin (Jan 15); Admin API requests with a non-expiring token return 403 (Apr 1, 2027)

New public apps have had to use expiring offline tokens since April 1, 2026; the Jan 1, 2027 date is for apps listed before that.

Sources: IP allowlists are now required for public apps, Restrict API access with an IP allowlist, Use expiring offline access tokens.

Allowlisting an app that runs on Cloudflare

Workers and Pages have no fixed outbound address, and Shopify’s network lookup (GeoLite) finds no ASN for Workers egress, so allowing Cloudflare’s ASN (13335) blocked every request in the Dev Dashboard’s test, even though Shopify’s guidance for serverless hosts is to allow the provider’s ASNs (requests with no ASN data are rejected). What works is Cloudflare’s published ranges (IPv4, IPv6), split to fit Shopify’s limits (IPv4 /16 or narrower, IPv6 /32 or narrower, up to 250 entries): 47 entries. Run the Dev Dashboard’s test against the last 30 days of traffic before turning enforcement on.

The limit of this: Cloudflare’s network is shared, so a leaked token still works from anyone’s Worker. It meets the rule; it is not isolation. Anything that calls Shopify from outside Cloudflare with the same token (Xano, a script, a webhook processor elsewhere) is blocked, so route those calls through the gate.

Not to be confused with network_access. The [network_access] section of shopify.app.toml, added in the same October 2026 security update, is a different control: it declares the outside hosts an app’s code loads from or sends requests to on store pages (allowed_sources, HTTPS origins) and the hosts shoppers can follow links to without an exit notice (allowed_navigation_hosts, up to 20). It applies once deployed with shopify app deploy. It does not restrict where Admin API tokens can be used; the IP allowlist is set only in the Dev Dashboard.

What the allowlist reaches in a Cloudflare and Xano stack

The allowlist applies to one direction only: calls into Shopify’s Admin API with a public app’s token. Calls from Shopify (webhooks), calls to Xano, Google or Webflow, and sign-in through Shopify’s Customer Account API are outside it. Checked on a live stack after enforcement was turned on:

PartIts path to ShopifyAffected?
PIM Sync (catalog, prices, translations to Webflow)Workers → Admin GraphQL, one request at a time. Reads page through products(first:, after:) with a cursor, plus single lookups (product, markets, locales, metafield definitions). Writes are ordinary mutations, one product or collection per call: productUpdate, metafieldsSet, translationsRegister, priceListFixedPricesAdd, productCreateMedia, publish and unpublish. It never calls bulkOperationRunQuery or bulkOperationRunMutationNo. Its Workers egress from Cloudflare, the token refresh that runs every 15 minutes kept succeeding, and the Nov 12 rule blocks only those two bulk mutations, which it doesn’t call
Webhooks into XanoShopify → Worker → XanoNo. Inbound to the app, not a call into the Admin API
The Configurator (one console in the Webflow Designer, a desktop app or a browser)Browser → Worker → ShopifyNo. The page never calls Shopify itself; the Worker does
BYO Cloudflare (a merchant’s own Cloudflare account)Their Worker → Admin APINo. Every Cloudflare account egresses from the same published ranges
BYO Xano (a merchant’s own Xano instance)Xano → Admin API directlyYes, with a public app’s token: 403. Route the call through a Worker, or allow the instance’s fixed outbound IP if its plan has one (a few entries at most, out of 250). Unaffected with the merchant’s own custom-app token, which is exempt
Login, Claims and Extras (see below)Worker → Customer Account API, Google, Xano; one Admin API lookup from the WorkerNo
Logs(none)Turn on Workers Logs ([observability] enabled = true in wrangler.toml) on every Worker that calls Shopify, so a 403 after enforcement can be searched rather than guessed at. Log shop domains and status codes, never tokens, secrets or a shopper’s email

The rule for BYO setups: Admin API calls with the public app’s token leave from Cloudflare. The merchant’s own Xano stays the system of record behind the Worker.

Login, TLS and /auth/me: Claims and Extras

TLS login. TLS (Transport Layer Security) is the encryption behind https://. A TLS login means every step of sign-in travels encrypted: the password or the OAuth code from the browser to Cloudflare’s edge, and the Worker’s own calls on to Xano, Google and Shopify. TLS protects the connection, not the identity: it stops anyone on the network reading or altering the login, but it doesn’t say who the person is. That is what the signed token does. Three separate controls, at three layers:

LayerControlAnswers
NetworkShopify’s IP allowlistIs this call coming from an allowed network?
TransportTLS (HTTPS)Can anyone read or change it on the way?
IdentityA signed session token (JWT), checked on every requestWho is this, and are they still allowed?

The login flow. A person signs in with email and password, Google, or Shopify’s Customer Account API (OpenID Connect, which is not covered by the Admin API allowlist). The Worker checks the result, links the identity to one person in Xano, and returns a signed session token. Logging out puts the token on a revocation list, so a copy left in a browser stops working at once rather than at expiry.

Claims. The facts about who the person is and which accounts are theirs, kept in Xano: the user ID, the linked provider identities (a Google subject ID, a Shopify customer ID), language and verified email. A login attaches to an existing person by email only when the inbox is proven.

Extras. The extra, per-person data a signed-in page may show beyond the claims, such as preferences and member-only content, kept in a separate Xano table so the claims stay minimal.

/auth/me. The endpoint the app calls on every open to ask “who is signed in?” It:

  1. reads the token from the Authorization: Bearer header and verifies its signature and expiry (401 if not);
  2. checks the person still exists and isn’t deleted, before anything writes (401 or 404 otherwise);
  3. reconciles the identities, linking a Google login and a Shopify customer to the same person; this is the one Admin API lookup in the flow, made by the Worker, so the allowlist passes it;
  4. returns logged_in, the user, the claims, the extras and the entitlement (what the person may do).

The entitlement it returns is a hint for the page, so it can hide controls the person can’t use. The Worker re-checks permissions on every request; nothing in the token or in /auth/me is trusted on its own.

Salt, hashing and encryption: what TLS doesn’t cover

TLS protects data while it moves: browser to Cloudflare, Worker to Xano, Worker to Shopify and Google. It does nothing for data once it’s stored. Four other controls cover that, and each one does a different job:

ControlDirectionUsed forIn this stack
TLSIn transitEvery connectionHTTPS from the browser to the Worker, and from the Worker to Xano, Shopify and Google
Salted password hashOne way: can be checked, never read backPasswordsThe Worker hashes; Xano stores only the salt and the hash
EncryptionTwo way: can be read back with the keyData the system must use again: files, configuration, tokensAES-GCM with 256-bit keys, under envelope encryption
Signed tokenChecked, not hiddenProving who a request is fromThe session token (JWT), signed with HMAC-SHA-256 using a secret only the Worker holds
Encryption at restStorageDisks and backupsThe cloud provider’s (Xano’s hosting, R2, KV)

What a salt is. A salt is a random value, different for every password, mixed in before hashing. Two people with the same password get different hashes, and a list of precomputed hashes for common passwords (a rainbow table) is useless, because each stored hash would need its own table. The salt is not secret; it is stored next to the hash. What it adds is that every password has to be attacked on its own.

How a password is stored here:

  1. The Worker generates a 16-byte random salt.
  2. It derives a 256-bit hash with PBKDF2-SHA-256 over 100,000 iterations. The iterations make each guess slow, so a stolen table of hashes is expensive to crack.
  3. Xano stores salt:hash. The password itself never reaches Xano, a log or a backup.
  4. At sign-in the Worker repeats the derivation with the stored salt and compares the result.

100,000 iterations is the maximum PBKDF2 allows in Cloudflare Workers, and below what OWASP currently recommends for PBKDF2-SHA-256 (600,000). Two ways to close the gap: a memory-hard hash (Argon2id, or bcrypt) compiled to WebAssembly in the Worker, or fewer passwords altogether, with sign-in through Google, Shopify or passkeys, where no password hash is stored at all.

Fail closed: the *sshole lesson. The OpenSSH bypass disclosed in November 2026 (sshhole.com) is a salt-and-hash bug. On musl-libc systems, crypt() returns * when it fails, a password over 256 characters makes it fail, and an account whose stored password is * (meaning “no password login”) then compares * with * and lets the login in. The rules that follow for any password check:

  • A failure is never a value that can match. If hashing fails, the check returns no; it never compares an error output.
  • A placeholder is never a hash. An empty field, * or ! means “no password”, and the check refuses before comparing. The check here returns no if the stored value doesn’t split into a salt and a hash.
  • Limit the input. Refuse passwords over a set length (for example 1,024 bytes) before hashing, rather than letting the hash function truncate or fail.
  • Compare in constant time (crypto.subtle.timingSafeEqual in Workers), so the time a comparison takes reveals nothing about how much of the hash matched.

Applying the rules: the password fix, test first

A review of this stack’s own sign-in against those four rules found two gaps. The stored-value check already failed closed, but the hash was compared as a string with ===, which stops at the first character that differs, and nothing limited the password’s length before the slow hash. The fix was written test first:

  1. The tests came first, and all 13 failed against the code as it was.
  2. One module (password.ts) replaced the inline functions, so the rules live in one place that can be tested on its own; signup, login and password reset all call it.
  3. All 13 passed, the full test gate ran before deploy, and an existing account signed in on production afterwards.
RuleBeforeAfterThe test that holds it
A placeholder is never a hashAn empty or one-part value returned noOnly a value of exactly the stored form (a 22-character salt, a colon, a 43-character hash) is considered at all*, !, '', :, null and others, each tried with a 300-character password, never verify; rows one character short or long are refused without being compared
A failure is never a value that can matchAn error while hashing would have thrownAny error is a refusal; a password that isn’t a string is refused, not crashed onNon-string passwords neither verify nor throw
Limit the inputNo upper limitAt most 1,024 bytes, counted in UTF-8 (a Korean character is 3 bytes), checked before any hashing; signup and reset say so, login answers “invalid credentials”1,025 bytes refused and 1,024 accepted; 342 three-byte characters (1,026 bytes) refused
Compare in constant timeString ===Byte comparison with crypto.subtle.timingSafeEqual in Workers, a constant-time loop elsewhere; empty values never matchCorrect for equal, first-byte, last-byte and different-length inputs; a static check that no string === remains
Existing passwords keep workingSame stored form: PBKDF2-SHA-256, 100,000 iterations, 16-byte saltA row hashed the old way still verifies, and a wrong password against it doesn’t

The one change a user could notice: a password longer than 1,024 bytes can no longer be set, and one set earlier would need a reset. The tests run in the deploy gate, so a later change that brings back a string comparison, an inline copy of the hashing, or a bare length check fails the build before it ships.

Envelope encryption for files. Each protected file (a 3D asset, for example) gets its own random 256-bit content key, which encrypts the file with AES-GCM; the ciphertext goes to R2. The content key is itself encrypted (“wrapped”) under a key-encryption key, derived with PBKDF2 from a master secret, a salt for that file and a key version. Only the wrapped key is stored, in KV. Rotating one file’s key re-wraps one small value instead of re-encrypting everything, and the master secret never leaves the Worker.

What Xano adds. Xano’s endpoints are HTTPS only, and its own password field type stores a hash rather than the password. Xano’s built-in authentication issues tokens encrypted as JWE, not merely signed. It also has security functions for hashing, HMAC and AES encryption, for teams that keep this logic inside Xano. Here the Worker does the hashing and the encryption, so Xano holds salts, hashes and ciphertext, and a copy of the Xano database on its own gives up no passwords and no plaintext files. Check your Xano plan’s settings for encryption at rest and backups.

The rule: TLS for the wire, a salted slow hash for passwords, encryption for anything that must be read back, a signature for identity, and every check failing closed.

mTLS: proving the caller is one of your machines

Ordinary TLS proves the server to the caller. Mutual TLS (mTLS) also makes the caller present a certificate you issued, checked during the TLS handshake, before a single request byte is read. It answers “is this one of my machines?” It does not answer who the person is, or whether a record can be trusted later. Those are other layers, and a stack needs each one for its own job:

LayerWhat it provesExample in this stack
mTLSThe connecting machine holds a certificate you issuedMuleSoft or SAP calling a B2B endpoint
Webhook HMACThe event really came from Shopify, for that apporders/paid to /webhooks/shopify
Bearer token (JWT)Which signed-in person is callingA buyer issuing a certificate at /attest
API keyWhich system or tenant is callingA Worker calling Xano
Signed certificate (Ed25519)A record was signed by your key and not changed since; anyone can check it laterLicense and attestation certificates, checked against /.well-known/jwks.json

Which platforms do what.

  • Cloudflare, inbound: API Shield checks client certificates at the edge. Every plan can use mTLS with a Cloudflare-managed certificate authority (CA); Enterprise can upload its own CAs. This is the mTLS for a MuleSoft-to-Cloudflare handoff.
  • Cloudflare, outbound: a Worker’s mTLS binding gives it a fetch() that presents a client certificate in the handshake. If the destination is itself proxied by Cloudflare, the call fails with a 520, so check where the destination is hosted first.
  • Xano: it can present a client certificate on outbound calls, but has no documented way to require one on its own endpoints. A Worker presenting a certificate to Xano would be checked by nobody, so keep calling Xano with its API key, and if something must reach Xano over mTLS, end the mTLS in front of it (Cloudflare, or a Rust gateway) and call Xano from there.

Where it fits. Put mTLS on the paths machines use, not on the storefront. For example, a /b2b/* path or a separate hostname for MuleSoft or SAP, with an API Shield rule requiring a valid client certificate and the existing API key still checked behind it. A stolen key alone then gets no one in, and a stolen certificate alone doesn’t either.

What mTLS does not do. It doesn’t map a certificate to a user or role (matching the certificate’s name to a caller is application logic), and it doesn’t revoke a certificate by itself: keep a revocation list (CRL) or use OCSP in the verifier.

On the IP allowlist. A Rust gateway on a static IP gives Shopify’s IP allowlist a single address to trust. That is tighter, but not required: Workers meet Shopify’s rule today by allowlisting Cloudflare’s published ranges (see “Allowlisting an app that runs on Cloudflare”), at the cost of trusting all of Cloudflare’s address space rather than one machine.

In Rust, Axum with rustls 0.23 ends mTLS like this. Leave out .allow_unauthenticated(), which would let callers without a certificate through. Tutorials written for rustls 0.21 (AllowAnyAuthenticatedClient, with_safe_defaults()) no longer compile.

#![allow(unused)]
fn main() {
use std::sync::Arc;
use axum_server::tls_rustls::RustlsConfig;
use rustls::server::WebPkiClientVerifier;

// client_ca_roots: the CA that issued your partners' certificates.
let verifier = WebPkiClientVerifier::builder(Arc::new(client_ca_roots)).build()?;
let config = rustls::ServerConfig::builder()
    .with_client_cert_verifier(verifier)
    .with_single_cert(server_certs, server_key)?;
axum_server::bind_rustls(addr, RustlsConfig::from_config(Arc::new(config)))
    .serve(app.into_make_service())
    .await?;
}

RuBAC compared with perimeter login (SAP role login)

Perimeter login decides access once, at the door. An SAP GUI logon is the familiar example: the user enters a client (the Client field, such as 400, chooses which company’s data set inside the system), a user name, a password and a logon language. Once past that screen, the user’s roles (built in transaction PFCG) decide what they can do. Each role carries authorization objects, such as S_TCODE for which transactions may run and field values such as a company code, and ABAP programs test them with AUTHORITY-CHECK. The roles are loaded into the user’s buffer at logon, so a role change generally takes effect at the next logon. The rest of the perimeter is the network around it: the VPN or the corporate network the SAP system sits inside.

That is RBAC (role-based access control): access follows the job title. It works inside one system with a known set of employees. It strains when the people are customers, partners and agents, when the permission has to follow a purchase or a consent rather than a job, and when the same permission must hold across WordPress, AEM, Salesforce, Webflow and Shopify at once.

RuBAC (rule-based access control) decides every request against rules over the current facts, not against a role handed out at login. A rule reads: this person may use pim.webflow if a license granting that term exists, hasn’t expired or been revoked, and consent for this purpose is in force in their region. The login only establishes who the person is; the entitlement register decides what they may do, each time they try.

Perimeter login (SAP roles, RBAC)RuBAC with an entitlement register
Where access is decidedOnce, at logon; then the session’s role bufferOn every request, by the Worker reading the register
What a permission isA role assigned to a user by an administratorA record: a license with its terms, granted by a purchase, an invitation or an admin, with a date and a proof
Who it’s forEmployees inside one systemCustomers, partners, merchants and AI agents, across several platforms
A change takes effectGenerally at the next logonOn the next request
RevocationRemove the role; open sessions keep the buffered authorizationsDelete or expire the record; the next request is refused
InputsUser, role, authorization object valuesIdentity plus the license terms, expiry, consent, region and the destination asked for
AuditChange documents on users and roles; security audit logGrant is an insert, revoke is a delete, audit is a select, each row with a timestamp and a receipt
Trust after loginThe session is trusted once it’s insideNothing is trusted on its own: not the token, not the page, not /auth/me
Across platformsEach system keeps its own rolesOne register; each platform renders and the Worker decides

How the two meet. An enterprise keeps SAP’s roles for employees working inside SAP; nothing here replaces them. What RuBAC adds sits outside the ERP: the permissions for people and agents who never get an SAP user, checked live through the same gate that checks consent. On an account page this shows as a list of licenses, each with its grant date, its terms (for example pim.sync, pim.webflow, pim.omnibus) and a proof link (a receipt that can be verified), beside an activity log of consent decisions. The login screen offers email, Shopify and Google; whichever is used, the same register answers.

One login, three ways in: email and password, Shopify, or Google. Any of them leads to the same person in the register.

The account page after sign-in. Each license row is a grant with its date, its terms and a verifiable proof; the activity log below records each consent decision and how it was made. A SAP logon screen has no equivalent of either: its roles are assigned behind the logon, and the user doesn’t see them.

The rule: perimeter login asks “are you inside?” once. RuBAC asks “may this person do this, now?” every time.

Which integrations the token rule reaches

The line that matters is public app or custom app, not how long a job runs.

IntegrationUsually connects asCoveredWho acts
Bulk import and export (Matrixify and similar)Public appYesThe vendor; the merchant may need to re-authorise
Fulfilment and warehouse (ShipHero, ShipBob and similar)Public appYesThe vendor
Email and CRM (Klaviyo and similar)Public appYesThe vendor
Loyalty and reviews appsPublic appYesThe vendor
Salesforce, SAP or NetSuite through middleware (Boomi, Celigo, MuleSoft, a custom connector)Often a custom app in the merchant’s admin, its static token pasted into the middlewareNo: exemptNo one is required to
The same middleware installed as a vendor’s public appPublic appYesThe vendor

The ERP link is the surprise. A custom-app token feeding SAP or Salesforce is exempt from both rules, so it never expires, works from anywhere and often can write orders and customers: frequently the most exposed credential in the store. Keep it read-mostly (see Licensing penalties by flow), hold it in one place behind the gate, and rotate it even though Shopify doesn’t force it.

How tokens worked before

Until expiring offline tokens, background tokens did not expire. An app’s token lasted until the app was uninstalled or the merchant revoked it, and expiry was not something anyone managed. (The Dev Dashboard is Shopify’s newer app-management console, replacing app management in the Partners Dashboard; WebAssembly belongs to Shopify Functions, covered below.)

EraHow an app got accessExpiryHow access ended
Private apps (deprecated around 2022)Created in the merchant’s admin: an API key and password sent with every requestNeverDelete the private app
Public app, OAuth offline tokenThe merchant approves scopes once; the app stores a permanent token in its own databaseNever, until uninstall, a revoke, or a scope change that needs re-approvalUninstall or revoke
Public app, OAuth online tokenTied to one logged-in staff member24 hours, or when that person logs out of the admin, whichever comes firstExpires on its own
Custom app (replaced private apps)The merchant creates the app and copies a static shpat_ token, shown onceNeverUninstall the custom app
Embedded app, token exchange (from around 2024)The app swaps the browser’s session token for an Admin API token, with no redirectOffline tokens from the exchange were still non-expiring at firstUninstall or revoke
Expiring offline token (required for public apps from Jan 1, 2027)An offline access token plus a refresh tokenAccess token 1 hour; refresh token 90 days when issued, replaced on every refreshLapses if unused; uninstall or revoke

The dates are approximate; Shopify phased each change in. What “management” meant before:

  • Storage was the app’s job. Each app kept its offline token in its own database, with no lifetime or rotation tooling from Shopify.
  • Rotation meant reinstalling. Rotating the app’s client secret changed signing (webhooks, for example), but stored offline tokens generally kept working. Replacing a token meant re-running OAuth or reinstalling.
  • No network limits. Before the allowlist, a leaked offline token worked from anywhere, indefinitely.
  • Monitoring was optional. Apps watched for 401s and deleted stored tokens on the app/uninstalled webhook.

Shopify Functions never held tokens. Functions run inside Shopify as WebAssembly (written in Rust or JavaScript), receive the data their input query asks for, and return a decision (a discount, a delivery option, a checkout validation). They make no network calls, so they were never part of the token problem, and they can’t ask the gate either: the gate’s decision has to be written beforehand where the Function reads it (see Parsing at the gate).

Why it matters now. Most long-running integrations were built when an offline token was permanent: they store one token and use it forever, with no refresh step. Moving to expiring tokens means each needs a refresh step, one place that refreshes, and a way to survive 90 quiet days. Custom-app ERP links skip all of it, because they are exempt, which is why they remain the most exposed credential in most stores.

Shopify and Google: both access tokens last one hour

The same design applies to both platforms, because both issue access tokens that last one hour:

Shopify Admin API (expiring offline token)Google APIs (OAuth 2.0: Ads, BigQuery, Merchant Center, YouTube)
Access token1 hour (expires_in 3600)1 hour (expires_in about 3599)
Refresh token90 days when issued; replaced on every refreshLong-lived and usually not replaced; it stops working when the user revokes access, after six months unused, when the user changes the password (for Gmail scopes), past the per-client limit of live refresh tokens, or after 7 days for an app whose consent screen is still in Testing
Server-to-server, no person presentClient credentials: a public app signs a JWT (RS256 or ES256) and gets a token of up to 1 hour, with no refresh token; a custom app on its own organization’s stores sends its client secret and gets 24 hoursA service account: the backend signs a JWT and gets a token of up to 1 hour, with no refresh token
A dead refresh token401 invalid_request; the merchant reopens the app400 invalid_grant; the user grants access again

So a job that pulls from Shopify and writes to BigQuery or Google Ads holds two one-hour tokens with different refresh rules. Give each its own owner in the job (the TokenOwner pattern below), refresh each before it expires, and never assume one’s lifetime from the other’s. Shopify’s rotating refresh token is the stricter of the two: two workers refreshing at once break it, which is not true of Google’s.

Signing in as the app: RS256 or ES256, not EdDSA

A background job with no merchant present (a nightly sync, a cron sweep) can get its own Admin token without a refresh token. Shopify has two versions of this, and which one an app gets depends on how it is distributed:

Custom app, stores in its own organizationPublic app, any store that installed it
What the app sendsclient_id and client_secretclient_id and a signed client_assertion (no secret)
Token lifetime24 hours (expires_in 86399)Up to 1 hour (expires_in 3599); read the value, don’t assume it
Refresh tokenNoneNone
Who can use itOnly when the app and the store belong to the same Shopify organizationAny store that has installed the app and approved its scopes

Shopify accepts two signing algorithms for the assertion: RS256 (RSA, 2048 to 8192 bits) and ES256 (EC, P-256). EdDSA (Ed25519) is not on the list. A design that labels its fallback “Ed25519 signer” should use ES256 instead. ES256 is the nearest equivalent: small keys and fast signing, and Cloudflare Workers’ WebCrypto supports it.

The request is a form post to https://{shop}.myshopify.com/admin/oauth/access_token:

grant_type=client_credentials
client_id=<app client ID>
client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
client_assertion=<JWT signed with the app's private key>

The assertion is a short JWT that Shopify checks part by part:

PartValue
alg (header)RS256 or ES256, matching the registered key
kid (header)The ID of an active public key on the app
iss, subThe app’s client ID
audhttps://{shop}.myshopify.com/admin/oauth/access_token, the store’s permanent domain
iat, expNow, and at most 300 seconds later
jtiUnique; Shopify accepts each one once per app, across all stores

Because each jti is accepted once, sign a new assertion for every request, retries included. Don’t send a client secret, an Authorization: Basic header or a scope in the same request. The public key is registered as a JWK (with kid, alg and use: "sig") in the Dev Dashboard, under the app’s Settings → Credentials → Public keys. The dashboard does not accept PEM.

Why it matters for long-running work. For a public app this replaces the refresh-token chain. Each time it needs Shopify, the job signs a new assertion and gets a new one-hour token: there is no refresh token to store, rotate or lose, no 90-day expiry, and no dead refresh token that waits on the merchant to reconnect. What remains is the install itself: the store has to keep the app installed with its scopes approved.

Keep it apart from other signing keys. A platform that already signs its own documents (license certificates, attestations) with an Ed25519 key keeps that key for that purpose. The Shopify assertion key is a separate ES256 key per app: the private half held as a secret in the Worker, the public half in the Dev Dashboard, and a new kid on every rotation.

In Rust, with the jsonwebtoken, serde and uuid crates, the assertion is a few lines. shop is the permanent domain (example.myshopify.com) and pem the PKCS#8 private key:

#![allow(unused)]
fn main() {
use jsonwebtoken::{encode, Algorithm, EncodingKey, Header};
use serde::Serialize;

#[derive(Serialize)]
struct Assertion<'a> { iss: &'a str, sub: &'a str, aud: String, iat: u64, exp: u64, jti: String }

fn client_assertion(client_id: &str, shop: &str, kid: &str, pem: &[u8], now: u64) -> jsonwebtoken::errors::Result<String> {
    let mut header = Header::new(Algorithm::ES256); // RS256 also accepted; EdDSA is not
    header.kid = Some(kid.to_string());
    let claims = Assertion {
        iss: client_id, sub: client_id,
        aud: format!("https://{shop}/admin/oauth/access_token"),
        iat: now, exp: now + 60,              // at most 300 seconds
        jti: uuid::Uuid::new_v4().to_string(), // new for every request, retries included
    };
    encode(&header, &claims, &EncodingKey::from_ec_pem(pem)?)
}
}

Migrating stored tokens: the options

An app built the old way holds a database of permanent offline tokens: one per shop, no expiry date, no refresh token. Before Jan 1, 2027 it has five ways forward (migration guide):

#OptionMerchant actionBest for
1Exchange each stored token for an expiring pair: POST /admin/oauth/access_token with grant_type=urn:ietf:params:oauth:grant-type:token-exchange, the stored token as subject_token (type urn:shopify:params:oauth:token-type:offline-access-token), the same requested_token_type, and expiring=1NoneAny app with working stored tokens: the main path
2The template flag: future: { expiringOfflineAccessTokens: true } in shopify.server.ts, then shopify app deployNoneApps on Shopify’s Remix or React Router template, which then store and refresh the tokens itself
3Application-only access (client credentials)NoneBackground sync; no long-lived token stays in the database
4Re-authenticate when the merchant opens the app (token exchange with the session’s ID token)Opens the appShops whose stored token is already dead, or whose exchange returns invalid_subject_token
5A merchant-created custom appCreates it in the adminEnterprise setups; custom apps are exempt

Doing nothing: delisted with no new installs on Jan 1, 2027 (existing installs keep working); merchants warned on Jan 15; from Apr 1, 2027 every Admin API call with the old token returns 403 (“Non-expiring access tokens are no longer accepted for the Admin API”).

The database change behind option 1:

  • New columns per shop: access_token, access_expires_at (now plus expires_in), refresh_token, refresh_expires_at (90 days when issued), and a lock or version column.
  • Delete the old token once the exchange succeeds: migration permanently invalidates it for Admin API calls.
  • One shop at a time, never two workers on the same shop. If a response is lost, the same request within seven days returns the same pair.
  • Refresh dormant shops at least once every 90 days, or the next job needs the merchant.
  • Treat 401 invalid_request on refresh as final: mark the shop “reopen the app” instead of retrying.
  • Shopify’s pages don’t give a rate limit for exchanging many shops, or say whether migration can be undone. Assume it can’t, and pace the batch.

By integration type: Klaviyo, Gorgias and Sprinklr, Attentive, Matrixify

The names describe the shape of each integration. They are not a statement about any vendor’s readiness; most will have migrated or will migrate before the deadline.

Integration shapeWhat it does with the tokenWhat breaks firstPath
Klaviyo-style (email, marketing)Continuous background sync of customers, orders and catalog for thousands of shops; writes email consent backSync workers on many machines refresh the same shop at once and break each other’s refresh tokenOption 1 in a paced batch with one token owner per shop, or option 3 so nothing is stored
Gorgias / Sprinklr-style (helpdesk, social care)Agents look up orders and customers on demand and act (refund, cancel, change an address); background pulls tooA refund in the middle of a ticket fails on an expired tokenOption 1; refresh before any action if under five minutes remain. Enterprise setups on per-merchant custom apps (option 5) are exempt
Attentive-style (SMS)High-volume, two-way sync of SMS subscribers and consentA compliance gap, not just an outage: a consent write that gets 403 or 401 means an unsubscribe never reaches Shopify, and another tool may keep texting the personOption 1, plus a dead-letter queue for failed consent writes and a daily reconciliation of consent between the two systems
Matrixify-style (bulk import, export, platform migration)Jobs of several hours; occasional use; scheduled feeds; bulk operations for exports and large numbers of mutations for imports; runs on the vendor’s serversThe 90-day refresh token lapses between uses, and a long job outlives several one-hour tokensOption 1, plus a background refresh for dormant shops every 60 to 80 days, one token owner that import and export workers ask, and checkpoints with writes keyed by row. Option 3 for scheduled jobs

For a merchant before a large migration with a Matrixify-style tool:

  • Open the app shortly before the run, so a quiet connection gets a fresh token.
  • Split very large imports by collection or date range, so a failure costs one batch.
  • Keep the source files and a pre-import export, so a half-finished import can be rolled back.
  • After Apr 1, 2027, a 403 about non-expiring tokens means the vendor hasn’t migrated.
  • For a subscriber or customer migration, reconcile email and SMS consent afterwards: a partial failure can leave people with the wrong status.

The common point: the token change is a data-management change, not only an authentication change. Each shape needs one owner per credential, refresh before expiry, one shop at a time, writes that are safe to retry, and a list of shops that need the merchant. The Klaviyo- and Attentive-style shapes add reconciliation, so a consent withdrawal is never lost; the Matrixify-style shape adds refreshes for dormant shops and checkpoints, so a quiet connection or a long job isn’t.

Dead letters: when a write can’t land

Webhooks make a promise awkward to keep. The sender wants a quick 2xx; Shopify and Webflow retry a failure a few times and then may switch the subscription off. So most handlers answer 200 whatever happens. The risk is that 200 also means “done” to the sender, which never sends it again: if the write behind it failed, the work is gone and nothing records it.

A dead-letter queue closes that gap. Work that fails is set aside with its error, instead of being retried forever or dropped, and a scheduled job delivers it later. The name comes from the post office’s dead-letter office for mail that can’t be delivered.

StepWhat happens
1. The write failsA 401, rejected data (userErrors), a missing credential, or the other side unreachable. The write reports the failure; it doesn’t return quietly
2. Save before answeringThe work is stored with its error and the time of the first failure, keyed by what it is (the item, the person), so the same work failing twice is one entry. Then the handler answers 200
3. Retry on a scheduleA cron delivers what it can and deletes it; what still fails waits longer each time (15 minutes, doubling, up to 6 hours)
4. Newer winsA newer change that lands clears the older saved one; a change from the other system after the failure supersedes it, so old data never overwrites new
5. Don’t hammer a dead credentialA shop waiting for the merchant to reconnect is skipped until it’s reconnected. A dead-letter refresh is the same idea for tokens: a refresh token that returns 401 invalid_request is final, so the shop is marked, the work waits, and it’s replayed after the merchant reopens the app
6. Say what is lateAnything pending past a set time (24 hours here) is logged as overdue on every run, where someone will see it

Applying it: two webhook fixes, test first

The same review that found the password gaps found this one in two public apps of this stack. Both answered 200 on a failed write and kept nothing. Each fix was written test first: the tests failed against the live code, passed after the change, and the fix was deployed and merged.

Reviews app: privacy webhooksPIM sync: Webflow to Shopify edits
What was lostA customer data request, a customer erasure or a shop erasure that failed to reach the worker doing it. The failure was logged; Shopify was told 200 and never resentA Webflow CMS edit (description, tags, metafields, a collection’s title or publish state) whose Shopify write failed. Webflow was told {processed: true}; a failed collection was even recorded as synced
Why it mattersLegal: Shopify gives 30 days to answer a data request, and an erasure that silently didn’t happen reads like one that didData: the storefront and the CMS drift apart, and nobody knows which edits are missing
Saved asdsr:pending:<type>:<shop>:<customer>webflow_dlq:<itemId>, holding the newest version of the edit
Retried byA new cron, every 30 minutesThe existing 15-minute cron, right after it refreshes tokens, so an edit waiting on a token goes out in the same run
LateOVERDUE after 24 hours; PAST DEADLINE after 30 daysOVERDUE after 24 hours, noting when the shop needs the merchant to reconnect
Tests1211

The rule from both: a 200 to the sender is a promise that the work is either done or saved. Answering 200 without either is how data drops between intervals: between one webhook and the next cron, between a token dying and a merchant reconnecting, between a failure and someone reading the log.

Example: a nightly SAP load through a bulk loader, longer than an hour

A common pattern: SAP (ECC or S/4HANA) exports materials, prices and stock every night, and a Matrixify-style bulk loader writes them to Shopify as a bulk mutation. Shopify doesn’t name any loader in its announcements; the example is the shape, not a vendor. With 200,000 variants the load takes two to three hours, so it outlives at least two access tokens.

The point that makes it workable: a bulk operation runs on Shopify’s side. The token is needed only to start the job, to check on it, and to fetch the result; nothing calls the Admin API while Shopify is applying the rows. So the token has to be fresh at four moments, not for three hours straight.

Time (UTC)StepToken needed?What can go wrong
01:00SAP extracts the night’s changes (change pointers on MATMAS, condition records for prices, stock by plant) to a CSV or IDoc fileNo (SAP side)The extract runs while users are still changing prices: take a consistent cut-off time and record it
01:20The loader maps SAP fields to Shopify: MATNR to SKU and handle, MAKTX to title, KBETR and KONWA to price and currency; it writes a JSONL file, one line per productNoUnit and currency conversions; a MATNR with leading zeros becoming a different SKU
01:30stagedUploadsCreate, upload the JSONL, then bulkOperationRunMutation (for example with productSet)Yes: refresh first if under five minutes remainSince Nov 12, 2026, blocked if the call comes from a server outside the app’s IP allowlist
01:30 to 03:45Shopify applies the rows. The loader waits for the bulk_operations/finish webhook, or polls the operation’s statusYes, for each poll. The 01:30 token expired at 02:30Polling with the expired token gets 401. The poller must ask the token owner, not keep its own copy
03:45Download the result file: one line per input line, with any errorsOnly to read the operation’s result URLPer-line errors (a missing option value, an invalid price) don’t fail the whole job; they have to be read
04:00Retry only the failed lines as a second, smaller bulk operation; reconcile counts against SAP; save a checkpointYesA full rerun instead of a retry of the failures doubles the load and the risk

What keeps the nightly load safe:

  • One token owner for the shop, which the starter, the poller and the downloader all ask. Two of them refreshing at once breaks Shopify’s rotating refresh token.
  • A nightly load keeps the refresh token alive. Each night’s refresh resets the clock, so the 90-day expiry is a risk only when the loads stop (a migration pause, a holiday freeze).
  • Calls from the allowed network. Starting and polling must come from servers in the app’s allowlist: the loader vendor’s, or a Worker if you run the loader.
  • Writes keyed by SKU or handle (productSet with an identifier), so retrying a line updates the same product instead of creating a second one.
  • No overlap. If last night’s operation is still running when tonight’s starts, wait or skip; check the operation’s status first. Shopify limits how many bulk operations a shop can run at once (check the current limit for your API version).
  • A cut-off time and a checkpoint. Record which SAP extract each load applied, so the next night’s delta starts from the right point and an audit can say which SAP state the storefront showed.
  • Bulk scopes. Shopify’s Nov 5, 2026 update says bulk queries and bulk mutations will each need their own access scope. Apps that ran a bulk operation in the last 180 days get them granted automatically; a loader that has been idle longer has to request them.
  • The deadline. The same update’s summary says “November 11” for apps using bulk operations, while its body and table say November 12, 11:59 PM ET. Plan for the 11th.

Where it isn’t a bulk operation. Inventory by location, metafields written one at a time, or an importer that sends ordinary mutations row by row makes thousands of Admin API calls over the three hours. That load needs everything in Threads, tasks and async in a long-running Rust job: refresh during the run, a bounded queue, a cap on concurrent requests to stay inside Shopify’s rate limit, idempotent writes and checkpoints.

Shopify to Google Merchant Center: sync on change or morning updates

Once the night’s load reaches Shopify, the same products have to reach Google Merchant Center, which feeds Shopping ads, free listings and YouTube shopping. There are two ways to move them, and they fail differently.

Sync on changeMorning updates
HowA Shopify webhook (products/update, inventory_levels/update) reaches the Worker, which sends that one product to Google’s Merchant APIOne scheduled batch after the night’s load finishes and reconciles: a feed file Google fetches, or a batch of Merchant API calls
How fresh Google isMinutes after the changeUp to a day old by evening
A price or stock change at 14:00Reaches Google within minutesAds show the old price until tomorrow morning; Google can flag a mismatch with the landing page and disapprove the item
A 200,000-variant bulk load at 01:30Floods: each updated product can fire a webhook, so Google receives 200,000 single updates over three hours, against its API quotasOne batch after 04:00, built from the bulk operation’s result file
What Google sees mid-loadA half-loaded catalog: some products with new prices, some with oldOnly the finished, reconciled state
Retries and orderWebhooks can arrive late, twice or out of order; each update needs a timestamp check so an older one doesn’t overwrite a newer oneOne run, one checkpoint; easy to rerun
TokensThe Worker holds a Google token (one hour) and refreshes it all dayOne Google token for a short run
Best forPrice, sale price and availability: the fields that cause disapprovals and pricing-law problems when staleTitles, descriptions, images, categories, product attributes: the fields that change with the catalog, not by the minute

The usual answer is both, split by field:

 SAP nightly ─▶ bulk load to Shopify (01:30–03:45) ─▶ reconcile ─▶ morning batch to Merchant Center (04:15)
                                                                    all fields, from the result file

 Shopify during the day ─▶ webhook ─▶ Worker (the gate) ─▶ Merchant API, price and availability only
                                       ignores changes made by the bulk load itself
  • During the bulk load, pause the on-change path (or let the Worker ignore updates tagged as coming from the load), then send one batch from the result file. Otherwise Google gets the catalog half-finished and the quota is spent three hours early.
  • During the day, send only the fields that matter by the minute: price, sale price, availability. A merchandiser’s price change or a sell-out reaches Google in minutes.
  • One record decides. The Worker sends Google what the system of record (Xano, behind the gate) says, keyed by the same product ID the crosswalk assigned, not whatever field arrived last.
  • Keep every product refreshed within 30 days. Merchant Center lets products expire when nothing has updated them for 30 days, so a product that never changes still needs the morning batch to touch it.
  • Two one-hour tokens. The day path holds a Google token as well as Shopify’s; each gets its own owner and its own refresh, as in Shopify and Google: both access tokens last one hour.

Where Shopify’s own Google channel fits. The Google & YouTube app syncs Shopify products to Merchant Center on its own schedule, and suits a store whose catalog lives in Shopify. Where SAP owns the catalog and Shopify is one destination, the split above gives control over timing: which fields are live within minutes, and when the catalog as a whole changes. Use one path per field, never two writers for the same field.

The data layer. Merchant Center performance and product status also come back to BigQuery through the Merchant Center transfer, once a day. That is reporting, not sync: it shows what Google held yesterday, which is the check that the morning batch and the day path are doing their jobs (see Extending the data: BigQuery transfers).

Where long-running work breaks with expiring tokens

FailureWhyWhat closes it
A long paginated pull fails partwayThe access token lasts one hour, so a longer job outlives itRefresh during the job; prefer bulk operations, which run on Shopify’s side and need the token only to start and poll
A seasonal job can’t runA refresh token not used within 90 days expires (a quarterly reconciliation, a holiday fulfilment sync, a points-expiry run). Shopify then returns 401 with invalid_request, and the merchant has to reopen the appStore sessions for the refresh token’s full life, refresh at least once before day 90, and test seasonal jobs before they’re needed
Two workers break each otherEvery refresh returns a new refresh token. The old one stays usable only until the newer one is used, a new token is acquired, 30 days pass after its first use, or its 90-day expiry, whichever comes first. A worker still holding the old one then failsOne refresher per shop, with a lock; every other worker asks it for the current token and always stores the newest refresh token
Copies go staleThe token was copied into a warehouse, an iPaaS or XanoOne place refreshes; the others fetch from it, as every other decision goes through the gate
The refresh token is lostA failed write, a wiped session store, a migration that went wrongShopify’s October 2026 update adds client credentials for public apps: the backend signs a short-lived JWT with the app’s private key (its public key registered in the Dev Dashboard) and gets an access token for a store that has the app installed, valid up to one hour, with no refresh token. The migration guide still treats an invalid refresh token as “the merchant must reopen your app”, so confirm which path applies before relying on it

Where long jobs should run

A job that runs for more than an hour (a catalog load, an ERP reconciliation, a long import) raises two separate questions: where it runs, and how it keeps access. A server answers the first. It doesn’t answer the second: the access token still lasts one hour wherever the job runs, so a server job refreshes during the run like any other.

JobBest fitWhy
Large export or import of catalog or ordersShopify bulk operationsShopify runs the job; the token is needed only to start it, check on it and download the result
Hours of per-record work (transforms, ERP lookups, retries)A server, container or queue workerRuns as long as needed, keeps state in memory, and has a fixed outbound IP for the allowlist
A long job split into short stepsCloudflare Workflows, or Queues with Durable ObjectsEach step is short, retries on its own and gets the current token, so no run outlives a token
The gate, webhooks, the app proxy, short reads and writesCloudflare WorkersRequests take milliseconds to seconds; per-request CPU limits are in minutes, not hours
A vendor’s import tool you don’t controlThe vendor’s serversAsk how its long jobs refresh tokens and whether it uses bulk operations
 Cloudflare Worker (gate)  ── starts the job, decides consent, issues the receipt
        │
        ├─ small or medium:   Workflow steps on Cloudflare (each step gets the current token)
        ├─ catalog-sized:     a Shopify bulk operation (Shopify does the work)
        └─ hours of custom work: a server or queue worker (fixed IP, one token owner, checkpoints)
                                   │
                                   └─ reports back to the gate → receipt in Xano

Threads, tasks and async in a long-running Rust job

On a server, the Rust core runs long loads on Tokio, Rust’s most widely used async runtime. Its model, briefly:

  • Async tasks, not one thread each. async fn code pauses at each .await (a network call, a channel send) and lets other work run. Tokio runs thousands of these tasks on a small pool of OS threads, about one per CPU core.
  • tokio::spawn starts a background task; a JoinSet collects a group of them and reports each result, so a failure isn’t lost.
  • CPU-heavy work goes to spawn_blocking. Parsing a large page or converting ECC records holds a thread for a while; spawn_blocking runs it on a separate pool so the async threads keep serving network calls.
  • Bounded channels give backpressure. If writing is slower than fetching, the producer waits instead of filling memory.
  • A semaphore caps work in flight, which keeps the job under Shopify’s rate limits. Shopify limits GraphQL by query cost and reports the remaining budget in each response: slow down when it runs low.
  • Ownership carries over. The token pair has one owner behind a lock; tasks borrow a copy of the current access token. The compiler rejects code that shares the pair without the lock.
  • Cancellation is explicit. A CancellationToken lets a deploy or shutdown stop the job between pages, after the last checkpoint, instead of mid-write.

Shopify’s cursor pagination is sequential (each page gives the cursor for the next), so the fetch runs as one producer in order, and the parallel part is the transform and write. A sketch, compiled against Tokio, with the Shopify call, the Rust core and Xano left as stubs:

#![allow(unused)]
fn main() {
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::sync::{mpsc, Mutex, Semaphore};
use tokio::task::JoinSet;
use tokio_util::sync::CancellationToken;

type Res<T> = Result<T, Box<dyn std::error::Error + Send + Sync>>;

#[derive(Clone)]
pub struct AccessToken { pub value: String, pub expires_at: Instant }

pub struct Row { pub id: String, pub raw: String }
pub struct Batch { pub cursor: Option<String>, pub rows: Vec<Row> }

/// The one owner of a shop's tokens. Every task borrows the current access token through `current()`;
/// only the owner refreshes, under a lock, and it always keeps the newest refresh token.
pub struct TokenOwner { inner: Mutex<(AccessToken, String)> }

impl TokenOwner {
    pub fn new(access: AccessToken, refresh_token: String) -> Self {
        Self { inner: Mutex::new((access, refresh_token)) }
    }

    pub async fn current(&self) -> Res<AccessToken> {
        let mut guard = self.inner.lock().await; // one refresher per shop
        let left = guard.0.expires_at.saturating_duration_since(Instant::now());
        if left < Duration::from_secs(5 * 60) {
            let (access, refresh_token) = refresh(&guard.1).await?; // returns a new pair every time
            *guard = (access, refresh_token);
        }
        Ok(guard.0.clone())
    }
}

/// Long load: one producer walks Shopify's cursor pages in order (cursors are sequential),
/// a bounded channel applies backpressure, and a limited number of workers transform and write.
pub async fn run_load(owner: Arc<TokenOwner>, start: Option<String>, cancel: CancellationToken) -> Res<()> {
    let (tx, mut rx) = mpsc::channel::<Batch>(8); // at most 8 pages waiting

    let producer = {
        let owner = owner.clone();
        let cancel = cancel.clone();
        tokio::spawn(async move {
            let mut cursor = start;
            loop {
                if cancel.is_cancelled() { break; }
                let token = owner.current().await?; // fresh token for every page
                let (rows, next) = fetch_page(&token, cursor.as_deref()).await?;
                tx.send(Batch { cursor: cursor.clone(), rows }).await?;
                match next { Some(n) => cursor = Some(n), None => break }
            }
            Res::Ok(())
        })
    };

    let limit = Arc::new(Semaphore::new(4)); // workers in flight, kept under the API's rate limit
    let mut workers = JoinSet::new();
    while let Some(batch) = rx.recv().await {
        let permit = limit.clone().acquire_owned().await?;
        workers.spawn(async move {
            let _permit = permit; // released when this task ends
            let records = tokio::task::spawn_blocking(move || parse(batch.rows)).await?; // CPU work off the async threads
            write_idempotent(&records).await?; // keyed by record ID, so a replay is harmless
            save_checkpoint(batch.cursor.as_deref()).await
        });
    }
    while let Some(done) = workers.join_next().await { done??; }
    producer.await??;
    Ok(())
}
}

What each part closes from the failure table above:

Part of the sketchFailure it closes
TokenOwner::current() refreshes under a lock, five minutes before expiry, and stores the new pairA long pull failing partway; two workers breaking each other’s refresh token
One producer, cursor pages in orderPages fetched out of order or twice
mpsc::channel(8)Memory filling up when writes are slower than fetches
Semaphore::new(4)Hitting Shopify’s rate limit with too many requests in flight
spawn_blocking(parse)Network calls stalling behind CPU-heavy parsing
write_idempotent + save_checkpointA job that stops at hour two starting over, or writing records twice when it resumes
CancellationTokenA deploy or shutdown cutting a write in half

Rust’s non-blocking runners compared with useState in JavaScript

Rust adds code runners that don’t block: Tokio tasks (spawn, JoinSet), a separate pool for heavy work (spawn_blocking), and coordination built into the runtime (channels, semaphores, cancellation). Together they manage data while it moves: how much is in flight, who owns it, where to resume, and when to stop. React’s useState does something else. It holds a value for one component on one screen, re-renders when the value changes, and loses it when the page reloads or the tab closes.

Rust with TokioJavaScript with React useState
What it managesData in flight across a long job: pages, tokens, checkpointsOne component’s display state in one browser tab
Where it runsA server, for hours if needed, on several threadsThe shopper’s or merchant’s browser, for as long as the tab stays open
Doing work at onceTasks run in parallel on a thread pool; CPU-heavy parsing moves to spawn_blocking so network calls keep movingOne event loop per tab. async/await interleaves waiting but doesn’t run in parallel; heavy work freezes the page unless it moves to a Web Worker
Limits and backpressureBuilt in: a bounded mpsc channel and a SemaphoreNone. Each fetch starts at once unless you write the limit yourself
Who may change the dataThe compiler enforces one owner, or a lock; two writers changing the same value at once can’t compileAny code holding the setter can change it; a stale value from an earlier render can overwrite a newer one
Surviving a failuresave_checkpoint and idempotent writes resume where the job stoppedState is gone on reload; nothing resumes
Stopping cleanlyCancellationToken finishes the current write, then stopsClosing the tab stops everything mid-request

In business terms: useState is a note on one person’s desk, useful while they’re working on the screen in front of them. The Rust runners are the operations floor behind it: a controlled intake queue, a work-in-progress limit, a capacity cap on partner systems, a separate back office for heavy work, restart points, and an orderly close. The page can show progress with useState; the record of what was loaded, and from where to continue, belongs to the server and to Xano.

The two aren’t rivals. A merchant’s admin screen uses useState to show a load’s progress bar; the load itself runs in Rust on a server and reports its checkpoint, which the screen reads. Keep anything that must survive a reload, a retry or a deploy out of component state.

Inside a Cloudflare Worker there is no Tokio thread pool. A Worker runs one event loop per isolate; Rust compiled for it is async (through wasm-bindgen-futures) but single-threaded, and each request has CPU-time limits. The same crate’s logic (types, parsing, decide) runs there; the hour-long orchestration does not. Split it into Workflow steps or queue messages, or run it on a server with Tokio.

Certification and authorization impact

The two rules reach further than the App Store listing. The Shopify side decides whether an app can be listed and installed. The merchant’s own certifications decide whether its auditors accept how integrations hold credentials.

On Shopify’s side

WhatImpact
App Store listing and reviewAn app missing either rule is delisted and can’t take new installs, and an app under review should meet both before it’s approved. Check the current App Store requirements before submitting
Built for Shopify statusDepends on being listed and meeting the App Store requirements, so delisting puts it at risk. Check the current Built for Shopify criteria
Protected customer data accessApproved per app and per level. The rules don’t change the approval itself, but a token that can be used from anywhere and never expires is hard to defend in the data-protection answers that approval asks for
Merchant authorization (OAuth)Moving to expiring tokens can force a re-authorization. A refresh token that lapsed after 90 days does too. Plan it so merchants aren’t asked to re-approve scopes unexpectedly. Never widen scopes in the same change
Custom apps in the merchant’s adminExempt from both rules. The merchant’s admin staff own the token, the scopes and the rotation, so the merchant’s own controls have to cover them

On the merchant’s certifications

The token and allowlist rules map onto access-control requirements most frameworks already have. The mapping below is a guide for preparing evidence; the auditor decides what counts.

FrameworkRequirement it touchesEvidence the rules provideGap the exempt custom-app token leaves
SOC 2 (Trust Services Criteria, CC6)Logical access: restrict access, authenticate system accounts, limit access from outside the boundaryExpiring tokens; an allowlist limiting the networks a token can be used from; Dev Dashboard logs of client IPsA static token in middleware, usable from anywhere, often with write scopes
ISO/IEC 27001:2022 (Annex A)Authentication information, secure authentication, access rights (A.5.17, A.8.5, A.5.18)Token lifetime and rotation; network restriction; one owner per credentialNo forced rotation, and the credential is copied into several systems
PCI DSS v4.0 (Requirement 8)Accounts used by systems and applications: managed, protected and changed periodically based on a risk analysis (8.6)Expiring and rotating tokens for public appsCustom-app tokens feeding order or payment-adjacent systems need their own rotation schedule. Card data itself stays out of Shopify app tokens
GDPR / UK GDPR (Art. 32)Security of processing appropriate to the riskShort-lived credentials, network limits, an audit trail per decisionA long-lived token with customer scopes, held by a processor, without its own limits
SAP’s own certification of an integrationSAP certifies the connector, not the Shopify side—The Shopify credential the connector uses is out of scope for SAP’s certification and has to be covered by the merchant’s controls

What to put in the evidence pack

  • Each public app’s allowlist and enforcement state, with the date it was turned on and the traffic test result.
  • Proof that installs use expiring offline tokens, plus the session lifetime that keeps refresh tokens alive.
  • An inventory of custom-app tokens: where each is stored, its scopes, its owner and its rotation date.
  • A receipt for each export from the gate’s ledger (Function gating), so access can be traced per decision, not just per system.

Before Jan 1

  • List the store’s installed apps and ask each vendor whether it has moved to expiring offline tokens.
  • Find the custom apps whose tokens sit in ERP or middleware: exempt, but review their scopes and rotation, and allowlist them too where the platform allows.
  • Run each seasonal job once, early, so a lapsed refresh token shows up before the season does.
  • Treat the deadline as a review point: an app that stops on Apr 1 is the moment to decide whether to replace it with a build behind the same gate.

Terms

TermStands forWhat it means here
ASNAutonomous System NumberThe number identifying one network operator’s part of the internet: Cloudflare is 13335, Amazon Web Services 16509, Google 15169. Shopify’s allowlist can accept ASNs instead of addresses, meaning “any request from this operator’s network”. It depends on Shopify’s lookup (GeoLite) matching the request to an ASN, which failed for Cloudflare Workers egress
Short-lived token(not an acronym)An access token that expires quickly. Shopify’s expiring offline access token lasts one hour, so a stolen copy stops working on its own
Refresh token(not an acronym)The longer-lived token (90 days when issued) used to get a new access token. Shopify replaces it on every refresh
IPInternet ProtocolAn address such as 104.16.0.0 (IPv4) or 2606:4700:: (IPv6)
CIDRClassless Inter-Domain RoutingThe /16 or /32 notation for a block of IP addresses. A smaller number after the slash means a larger block
OAuthOpen AuthorizationHow a merchant approves an app’s access and the app receives its tokens
JWTJSON Web TokenA signed token. In Shopify’s client credentials flow, the app’s backend signs one with its private key to get an access token
JWKJSON Web KeyThe public key, registered in the Dev Dashboard, that Shopify uses to check that JWT
GIDGlobal IDShopify’s identifiers, such as gid://shopify/Product/123
Client assertion(not an acronym)A short JWT the app signs to prove it is the app, sent instead of a client secret when asking Shopify for a token
RS256RSA signature with SHA-256One of the two algorithms Shopify accepts for a client assertion (RSA keys of 2048 to 8192 bits)
ES256ECDSA on P-256 with SHA-256The other algorithm Shopify accepts; small keys and fast signing, the nearest equivalent to Ed25519
EdDSAEdwards-curve Digital Signature AlgorithmSigning with Ed25519 keys. Not accepted by Shopify for client assertions; fine for a platform’s own certificates
kidKey IDThe label in a signed token’s header saying which registered public key checks it; a new one on every key rotation
jtiJWT IDA unique ID per token. Shopify accepts each client assertion’s jti once per app, across all stores
mTLSMutual Transport Layer SecurityTLS in which the caller also presents a certificate you issued, checked in the handshake; proves the machine, not the person
CACertificate authorityWhoever issues and signs certificates; for mTLS, the CA you trust for your callers’ certificates
API Shield(Cloudflare product)Cloudflare’s API protection; its mTLS rules require a valid client certificate on chosen hostnames or paths
CRL / OCSPCertificate Revocation List / Online Certificate Status ProtocolThe two ways to tell a verifier a certificate has been withdrawn before it expires
Dead-letter queue(not an acronym)Where work that failed is set aside with its error, to be retried on a schedule instead of being dropped or retried forever
Dead-letter refresh(not an acronym)A token refresh that can never succeed (401 invalid_request): stop retrying, mark the shop, keep its waiting work, and replay it after the merchant reconnects
Bulk operation(not an acronym)A job Shopify runs on its own side over a whole dataset, started with bulkOperationRunQuery (export to a JSONL file) or bulkOperationRunMutation (apply an uploaded JSONL file), then polled or reported by the bulk_operations/finish webhook. Not the same as mutations with “bulk” in their name, such as productVariantsBulkUpdate, which are ordinary single requests. The Nov 12, 2026 allowlist rule applies to bulk operations only
APIApplication Programming InterfaceThe Admin API is how apps read and write store data
TLSTransport Layer SecurityThe encryption behind https://. A TLS login keeps every step of sign-in encrypted in transit; it protects the connection, not the identity
Salt(not an acronym)A random value, different for every password, mixed in before hashing so identical passwords give different hashes. Stored beside the hash; not secret
PBKDF2Password-Based Key Derivation Function 2A slow, salted hash for passwords and for deriving keys from a secret; its iterations set how slow
AES-GCMAdvanced Encryption Standard, Galois/Counter ModeTwo-way encryption that also detects tampering; used here with 256-bit keys
JWEJSON Web EncryptionA token whose contents are encrypted, not only signed; Xano’s built-in auth tokens use it
OIDCOpenID ConnectThe sign-in standard on top of OAuth that Google and Shopify’s Customer Account API use to say who a person is
Claims(not an acronym)The facts about who a signed-in person is and which accounts are linked to them, kept in Xano
Extras(not an acronym)Extra per-person data a signed-in page may show, kept apart from the claims
/auth/me(an endpoint)Answers “who is signed in?”: verifies the token, then returns the user, claims, extras and entitlement
RBACRole-based access controlAccess follows an assigned role, as with SAP roles built in PFCG and loaded at logon
RuBACRule-based access controlEvery request is decided by rules over current facts: a license and its terms, its expiry, consent and region
Perimeter login(not an acronym)Access decided once at the door (a logon screen, a VPN); inside, the session is trusted
Entitlement register(not an acronym)The record of who holds which license terms, read by the Worker on every request
BYOBring your ownA merchant running the stack on their own Cloudflare account or Xano instance

References