jackwener/OpenCLI · error · AuthRequiredError

Sign in to grok.com in your browser, then retry.

Error message

Sign in to grok.com in your browser, then retry.

What it means

The grok history command drives a real browser page, ensures it is on grok.com, then checks isLoggedIn before scraping the sidebar. If the page has no signed-in Grok session, it throws an AuthRequiredError (via authRequired(), clis/grok/utils.js:17) whose message tells the user to sign in to grok.com in the browser and retry. History data is only available to authenticated accounts.

Source

Thrown at clis/grok/history.js:36

    browser: true,
    siteSession: 'persistent',
    navigateBefore: false,
    args: [
        { name: 'limit', type: 'int', default: 20, help: 'Max conversations to show (default 20, max 100)' },
    ],
    columns: ['Index', 'Title', 'Url'],
    func: async (page, kwargs) => {
        const limit = Number(kwargs.limit ?? 20);
        if (!Number.isInteger(limit) || limit <= 0) {
            throw new ArgumentError('limit', 'must be a positive integer');
        }
        if (limit > 100) {
            throw new ArgumentError('limit', 'must be <= 100');
        }
        await ensureOnGrok(page);
        await page.wait(2);
        if (!(await isLoggedIn(page))) {
            throw authRequired();
        }
        const sessions = await getHistoryFromSidebar(page, limit);
        if (!sessions.length) {
            throw new EmptyResultError('grok history', 'No Grok conversations found in the sidebar for the signed-in account.');
        }
        return sessions.slice(0, limit).map((s, i) => ({
            Index: i + 1,
            Title: s.title || '(untitled)',
            Url: `https://grok.com/c/${s.id}`,
        }));
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open grok.com in the same browser profile the CLI drives and sign in, then rerun the command.
  2. Verify you are pointing the CLI at the profile that holds the logged-in session (not a fresh automation profile).
  3. Check that cookie-clearing settings/extensions are not wiping grok.com sessions between runs.
  4. If already signed in, reload grok.com and retry — a stale page state can fail the isLoggedIn probe.

Example fix

// before: opencli grok history on a logged-out profile -> AuthRequiredError
// after: open grok.com in the automation profile, complete sign-in, then rerun: opencli grok history
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const sessions = await grokHistory(limit);
} catch (e) {
  if (/Sign in to grok\.com/i.test(e.message) || e.name === 'AuthRequiredError') {
    // prompt: open grok.com in the driven profile, sign in, then retry
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Running the grok history command against a profile where the user is logged out of grok.com (isLoggedIn returns false), or whose session cookie expired; also triggered when automation lands on a logged-out page state after ensureOnGrok.

Common situations: Fresh browser profile with no grok.com login; cookies cleared by privacy settings or cleanup extensions; expired session after weeks of inactivity; running the CLI with a different profile than the one where you signed in.

Related errors


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