[object Object]

← back to Interiordesignershowroom

Fix adapter bugs from adversarial review: Rakuten token endpoint Basic (was Bearer, would 401 forever); CJ add category to GraphQL selection

9d15d2b0cfc00659603b2e304c3a728937e38378 · 2026-08-01 11:23:59 -0700 · Steve Abrams

Files touched

Diff

commit 9d15d2b0cfc00659603b2e304c3a728937e38378
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sat Aug 1 11:23:59 2026 -0700

    Fix adapter bugs from adversarial review: Rakuten token endpoint Basic (was Bearer, would 401 forever); CJ add category to GraphQL selection
---
 lib/adapters/cj.js      | 1 +
 lib/adapters/rakuten.js | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/adapters/cj.js b/lib/adapters/cj.js
index 4d6c672..7345069 100644
--- a/lib/adapters/cj.js
+++ b/lib/adapters/cj.js
@@ -115,6 +115,7 @@ async function fetch_(env, opts) {
           title
           description
           brand
+          category
           advertiserId
           advertiserName
           price { amount currency }
diff --git a/lib/adapters/rakuten.js b/lib/adapters/rakuten.js
index 31afc38..13ce92b 100644
--- a/lib/adapters/rakuten.js
+++ b/lib/adapters/rakuten.js
@@ -152,7 +152,11 @@ async function getAccessToken(env) {
     res = await fetch(TOKEN_URL, {
       method: 'POST',
       headers: {
-        Authorization: `Bearer ${basic}`,
+        // OAuth2 RFC 6749 §2.3.1 + Rakuten token endpoint: client credentials
+        // are sent as HTTP Basic auth (scheme "Basic"), NOT "Bearer".
+        // Using "Bearer" here would cause a 401 on every token request, silently
+        // making getAccessToken() always return null and fetch() always return [].
+        Authorization: `Basic ${basic}`,
         'Content-Type': 'application/x-www-form-urlencoded',
         Accept: 'application/json',
       },

← 7c4cdd2 Add 3 editorial buying guides (small-space sectionals, light  ·  back to Interiordesignershowroom  ·  Add gated /admin curation dashboard + dotenv env loading 5637f88 →