[object Object]

← back to Dw Yolo Loop

TK-11055: lib/shopify.mjs prefer SHOPIFY_FULL_ACCESS_TOKEN for write_inventory scope

9270cd2b8c7eec8fe428ce0c6c91a15ca5cdbbd7 · 2026-09-01 04:03:51 -0700 · Steve Abrams

Mirror of designerwallcoverings fix — same root cause, same fix.

Files touched

Diff

commit 9270cd2b8c7eec8fe428ce0c6c91a15ca5cdbbd7
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue Sep 1 04:03:51 2026 -0700

    TK-11055: lib/shopify.mjs prefer SHOPIFY_FULL_ACCESS_TOKEN for write_inventory scope
    
    Mirror of designerwallcoverings fix — same root cause, same fix.
---
 scripts/lib/shopify.mjs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/lib/shopify.mjs b/scripts/lib/shopify.mjs
index 267920b..15f1908 100644
--- a/scripts/lib/shopify.mjs
+++ b/scripts/lib/shopify.mjs
@@ -20,11 +20,14 @@ import fs from 'node:fs';
 
 export const SHOP = 'designer-laboratory-sandbox.myshopify.com';
 export const VER = '2024-10';
+const _env = fs.readFileSync(process.env.HOME + '/Projects/secrets-manager/.env', 'utf8');
+// Prefer the full-scope token (write_inventory + all others); fall back to the narrow custom-app token.
+// TK-11055: onboarders that call inventoryItemUpdate need write_inventory scope, which the narrow
+// SHOPIFY_ADMIN_TOKEN (…7d19, 4 scopes) lacks. SHOPIFY_FULL_ACCESS_TOKEN has 139 scopes.
 export const TOKEN = (
-  fs.readFileSync(process.env.HOME + '/Projects/secrets-manager/.env', 'utf8')
-    .match(/^SHOPIFY_ADMIN_TOKEN=(.+)$/m) || []
+  _env.match(/^SHOPIFY_FULL_ACCESS_TOKEN=(.+)$/m) || _env.match(/^SHOPIFY_ADMIN_TOKEN=(.+)$/m) || []
 )[1]?.trim();
-if (!TOKEN) { console.error('no SHOPIFY_ADMIN_TOKEN in ~/Projects/secrets-manager/.env'); process.exit(1); }
+if (!TOKEN) { console.error('no SHOPIFY_FULL_ACCESS_TOKEN or SHOPIFY_ADMIN_TOKEN in ~/Projects/secrets-manager/.env'); process.exit(1); }
 
 export const ENDPOINT = `https://${SHOP}/admin/api/${VER}`;
 const GQL_URL = `${ENDPOINT}/graphql.json`;

← 25ac473 feat: read-only GMC full-leak-list exporter (TK-10862 sessio  ·  back to Dw Yolo Loop  ·  TK-10952: gmc-feed-guard — add unhandledRejection handler fo 1956af9 →