jackwener/OpenCLI · error · AuthRequiredError

coupang.com

Error message

coupang.com

What it means

AuthRequiredError (exit code 77, code AUTH_REQUIRED) raised when the extraction's loginHints show the page has a login link but no 'My Coupang' marker, meaning the connected Chrome profile is not logged in to coupang.com. The library refuses to proceed because product data may be gated or the page is an anonymous/blocked variant.

Source

Thrown at clis/coupang/product.js:229

            throw new ArgumentError('Either --product-id or --url is required');
        }
        const productId = rawProductId
            ? requireProductIdArg(rawProductId, 'product-id')
            : requireProductIdArg(kwargs.url, '--url');
        const targetUrl = canonicalizeProductUrl(kwargs.url, productId);
        const finalUrl = targetUrl || canonicalizeProductUrl('', productId);
        await page.goto(finalUrl).catch((error) => {
            throw new CommandExecutionError(`coupang product navigation failed: ${error?.message || error}`);
        });
        await page.wait(2).catch((error) => {
            throw new CommandExecutionError(`coupang product wait failed: ${error?.message || error}`);
        });
        const result = await page.evaluate(buildProductDetailEvaluate(productId)).catch((error) => {
            throw new CommandExecutionError(`coupang product extraction failed: ${error?.message || error}`);
        });
        const loginHints = result?.loginHints ?? {};
        if (loginHints.hasLoginLink && !loginHints.hasMyCoupang) {
            throw new AuthRequiredError('coupang.com', 'Please log into Coupang in Chrome and retry.');
        }
        if (result?.reason === 'PRODUCT_MISMATCH') {
            const actualProductId = normalizeProductId(result?.currentProductId || '');
            const observed = actualProductId ? `got ${actualProductId}` : 'no product id observed';
            throw new EmptyResultError('coupang product', `Product page redirected: expected ${productId}, ${observed} (item may be sold out or unavailable in your region)`);
        }
        if (!result?.ok || !result?.data) {
            throw new EmptyResultError('coupang product', `No product data extracted from ${finalUrl}. The page may have failed to render or this product is restricted.`);
        }
        const actualProductId = normalizeProductId(result?.currentProductId || result.data.product_id || productId);
        const data = result.data;
        return [{
                product_id: actualProductId,
                title: data.title || null,
                price: data.price ?? null,
                original_price: data.original_price ?? null,
                discount_rate: data.discount_rate ?? null,
                rating: data.rating ?? null,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open Chrome (the profile connected to opencli), go to https://www.coupang.com and log in.
  2. Confirm you land on the logged-in state (My Coupang visible), then re-run the command.
  3. If cookies keep expiring, check the Chrome profile isn't set to clear cookies on exit.
  4. Verify the correct profile is connected to the daemon (profile-disconnected vs the one with the session).
Defensive patterns

Strategy: validation

Validate before calling

// check login state before running
const res = await fetch('https://www.coupang.com/', { headers: { cookie:coupangCookies } });
const html = await res.text();
const loggedIn = html.includes('My Coupang') || !html.includes('login');
if (!loggedIn) throw new Error('Log into coupang.com in Chrome first');

Type guard

function isAuthRequired(err) { return err?.code === 'AUTH_REQUIRED' && err?.domain === 'coupang.com'; }

Try / catch

try {
  return await run('coupang product', { url });
} catch (err) {
  if (err?.code === 'AUTH_REQUIRED') {
    console.error('Open Chrome, log in to https://www.coupang.com, then retry.');
    process.exit(77);
  }
  throw err;
}

Prevention

When it happens

Trigger: `opencli coupang product` where the evaluated page reports hasLoginLink === true and hasMyCoupang === false — i.e. Coupang served the logged-out experience or a login-required interstitial.

Common situations: Fresh Chrome profile never logged into Coupang; cookies expired/cleared; using a profile different from the one where the user logged in; Coupang logged the session out server-side; incognito-like isolated profile.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/1d70cce74d7904f2. Report an issue: GitHub.