jackwener/OpenCLI · error

AUTH

AUTH

Error message

AUTH

What it means

Inside collectHistory's page.evaluate for grok export-all, the script detects sign-in CTAs (buttons/links reading 'Sign in'/'Log in') while no history entries or history launcher exist, and returns { ok:false, code:'AUTH' }. The Node side surfaces this as an AUTH error meaning grok does not consider this browser session logged in, so conversation history cannot be exported.

Solutions

  1. Open grok.com in the connected Chrome/Chromium profile and sign in manually, then re-run the export
  2. Verify the CLI is attached to the browser profile you actually use (not a clean automation profile)
  3. After logging in, confirm the left sidebar shows past conversations before re-running
  4. Re-run the command — the page-state sniff is re-evaluated each run

Example fix

// before
$ opencli grok export-all   # AUTH error on fresh profile
// after
$ opencli browser connect --profile daily   # attach to logged-in profile
$ opencli grok export-all
Defensive patterns

Strategy: fallback

Validate before calling

// Before exporting, verify the session:
const ok = await page.evaluate(() => Boolean(document.querySelector('a[href^="/c/"]')));
if (!ok) throw new Error('Not logged in to grok — open grok.com and sign in first');

Try / catch

try {
  await grokExportAll();
} catch (e) {
  if (String(e.message).trim() === 'AUTH' || /AUTH/.test(e.code ?? e.message)) {
    console.error('Grok session invalid — open grok.com in the connected browser and sign in.');
  } else throw e;
}

Prevention

When it happens

Trigger: Running the grok export when the browser profile has no valid grok.com session: cookies expired/cleared, logged out manually, or the CLI attached to a fresh profile that never logged in — combined with the history sidebar showing no '/c/' entries and no 'Show all' launcher.

Common situations: Site logged you out after a password change or security sweep; using an automation profile (fresh Chrome profile) instead of your daily browser; cookie expiry after ~weeks; account region/SSO change requiring re-login.

Related errors


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

Appendix: source

Thrown at clis/grok/export-all.js:71

  await page.wait(2);
  const rawResult = await page.evaluate(`(async () => {
    const targetLimit = ${JSON.stringify(limit > 0 ? offset + limit : 0)};
    const maxScrolls = ${JSON.stringify(maxScrolls)};
    const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
    const isVisible = (node) => {
      if (!(node instanceof Element)) return false;
      const style = window.getComputedStyle(node);
      if (style.visibility === 'hidden' || style.display === 'none') return false;
      const rect = node.getBoundingClientRect();
      return rect.width > 0 && rect.height > 0;
    };
    const hasHistoryEntry = Boolean(document.querySelector('a[href^="/c/"]'));
    const hasHistoryLauncher = Array.from(document.querySelectorAll('button, [role="button"]'))
      .some((node) => isVisible(node) && /^(查看全部|show all|view all)$/i.test((node.textContent || '').trim()));
    const signInCta = Array.from(document.querySelectorAll('button, a'))
      .some((node) => isVisible(node) && /^(sign in|log in)$/i.test((node.textContent || '').trim()));
    if (signInCta && !hasHistoryEntry && !hasHistoryLauncher) {
      return { ok: false, code: 'AUTH' };
    }

    const clickAllHistory = () => {
      const buttons = Array.from(document.querySelectorAll('button, [role="button"]'))
        .filter((node) => node instanceof HTMLElement && isVisible(node));
      const target = buttons.find((node) => /^(查看全部|show all|view all)$/i.test((node.textContent || '').trim()));
      if (!target) return false;
      target.click();
      return true;
    };

    if (!document.querySelector('[role="listbox"] a[href^="/c/"]')) {
      clickAllHistory();
    }

    let listbox = null;
    for (let attempt = 0; attempt < 30; attempt += 1) {
      listbox = document.querySelector('[role="listbox"]');

View on GitHub (pinned to 49907e53dc)