{"record":{"id":"c258087389f6efd6","repo":"jackwener/OpenCLI","slug":"sign-in-to-grok-com-in-the-browser-then-retry","errorCode":null,"errorMessage":"Sign in to grok.com in the browser, then retry.","messagePattern":"Sign in to grok\\.com in the browser, then retry\\.","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"critical","filePath":"clis/grok/export-all.js","lineNumber":151,"sourceCode":"      collect();\n      if (targetLimit > 0 && seen.size >= targetLimit) break;\n      if (seen.size === lastCount && scroller.scrollHeight === lastHeight) {\n        stableRounds += 1;\n      } else {\n        stableRounds = 0;\n        lastCount = seen.size;\n        lastHeight = scroller.scrollHeight;\n      }\n      if (targetLimit === 0 && stableRounds >= 8) break;\n    }\n\n    return { ok: true, rows: Array.from(seen.values()) };\n  })()`);\n\n  const result = requireObjectEvaluateResult(rawResult, 'grok export-all history dialog');\n  if (result.ok !== true) {\n    if (result?.code === 'AUTH') {\n      throw new AuthRequiredError(GROK_DOMAIN, 'Sign in to grok.com in the browser, then retry.');\n    }\n    if (result?.code === 'NO_DIALOG') {\n      throw new TimeoutError('grok export-all history dialog', 8);\n    }\n    throw new EmptyResultError('grok export-all', 'No Grok conversation history was visible.');\n  }\n  const validRows = normalizeConversationRows(result.rows, 'grok export-all history dialog');\n  if (!validRows.length) {\n    throw new EmptyResultError('grok export-all', 'No Grok conversations found in the signed-in account history.');\n  }\n  return limit ? validRows.slice(offset, offset + limit) : validRows.slice(offset);\n}\n\nasync function readConversation(page, conversation, { pageTimeoutMs, pageScrolls, delayMinMs, delayMaxMs }) {\n  await page.goto(conversation.url);\n  const startedAt = Date.now();\n  let loaded = false;\n","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/grok/export-all.js#L133-L169","documentation":"AuthRequiredError thrown by collectHistory when the in-page history export reports code 'AUTH', meaning Grok redirected to a sign-in flow. The library requires an already-authenticated browser session before it can open the export-all history dialog.","triggerScenarios":"clis/grok/export-all.js:151 throws when the evaluate result from the history-dialog script returns { ok:false, code:'AUTH' } — the page is not signed in to grok.com.","commonSituations":"Cookie/session expired; running in a fresh browser profile that never logged in; incognito profile; corporate proxy or region forcing a login wall.","solutions":["Open grok.com in the automation browser and sign in manually, then retry","Reuse a persistent browser profile where you already logged in","Point the CLI at the profile/user-data-dir holding valid cookies","Re-authenticate and confirm your account loads the history page before running the export"],"exampleFix":"// before\nnpx grok export-all # fresh profile, no session\n// after\n# 1) launch browser with persistent profile, sign in to grok.com\n# 2) npx grok export-all --profile ./browser-profile","handlingStrategy":"try-catch","validationCode":"// pre-check: session cookie present in the automation profile\nconst cookies = await browser.cookies({ domain: 'grok.com' });\nif (!cookies.some(c => c.name.includes('session') || c.name.includes('auth'))) console.warn('No Grok session cookie — sign in first');","typeGuard":null,"tryCatchPattern":"try { await cli.exportAll(); } catch (e) { if (e.name === 'AuthRequiredError') { await openBrowserAndSignIn(); return cli.exportAll(); } throw e; }","preventionTips":["Use a persistent profile and sign in once","Re-authenticate when cookies expire (session age checks)","Avoid incognito/ephemeral contexts for scraping runs","Smoke-test a signed-in page load before export"],"tags":["authentication","session-expired","scraping"],"backgroundTag":"auth-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}