{"record":{"id":"56bd87ab1153d87c","repo":"jackwener/OpenCLI","slug":"notebooklm-redirected-to-google-sign-in","errorCode":null,"errorMessage":"NotebookLM redirected to Google sign-in","messagePattern":"NotebookLM redirected to Google sign-in","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/notebooklm/auth.js","lineNumber":39,"sourceCode":"        return { kind: 'auth', detail: 'NotebookLM redirected to Google sign-in' };\n      }\n      const acctEl = document.querySelector('a[aria-label^=\"Google Account:\"], a[aria-label*=\"Google 账号:\"]');\n      if (!acctEl) {\n        return { kind: 'auth', detail: 'NotebookLM missing Google Account button' };\n      }\n      const label = acctEl.getAttribute('aria-label') || '';\n      const nameMatch = label.match(/Google Account:\\\\s*([^\\\\n\\\\(]+?)(?:\\\\s*\\\\n|\\\\s*\\\\()/i) ||\n                        label.match(/Google 账号:\\\\s*([^\\\\n\\\\(]+?)(?:\\\\s*\\\\n|\\\\s*\\\\()/i);\n      const name = nameMatch ? nameMatch[1].trim() : '';\n      const authuserMatch = location.href.match(/[?&]authuser=(\\\\d+)/);\n      const authuser = authuserMatch ? Number(authuserMatch[1]) : 0;\n      if (!name) {\n        return { kind: 'auth', detail: 'NotebookLM Google Account aria-label found but name unparseable' };\n      }\n      return { ok: true, name, authuser };\n    })()\n  `));\n  if (probe?.kind === 'auth') throw new AuthRequiredError(NOTEBOOKLM_DOMAIN, probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected NotebookLM probe: ${JSON.stringify(probe)}`);\n  return { name: probe.name, authuser: probe.authuser };\n}\n\nregisterSiteAuthCommands({\n  site: 'notebooklm',\n  domain: 'google.com',\n  loginUrl: `https://accounts.google.com/ServiceLogin?service=lso&continue=${encodeURIComponent(NOTEBOOKLM_HOME_URL)}`,\n  columns: ['name', 'authuser'],\n  quickCheck: hasNotebookLmSsoCookies,\n  verify: verifyNotebookLmIdentity,\n  poll: async (page) => {\n    if (!await hasNotebookLmSsoCookies(page)) {\n      throw new AuthRequiredError(NOTEBOOKLM_DOMAIN, 'Waiting for Google SSO cookies (SID + SAPISID)');\n    }\n    return verifyNotebookLmIdentity(page);\n  },\n});","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/notebooklm/auth.js#L21-L57","documentation":"After SSO cookies are present, verifyNotebookLmIdentity navigates to NotebookLM and probes the page. If the in-page probe detects a redirect to Google sign-in (or the account chip reports an auth problem), it throws AuthRequiredError with the probe's detail as the message. This means cookies exist but the session is not actually valid for NotebookLM.","triggerScenarios":"Cookies SID/SAPISID exist but page.goto(NOTEBOOKLM_HOME_URL) redirects to accounts.google.com sign-in, or the probe script returns { kind: 'auth', detail: ... } (e.g. aria-label found but name unparseable).","commonSituations":"Expired SAPISID authorization while SID lingers; logged-out of the specific Google account; Google forcing re-verification; wrong authuser slot selected.","solutions":["Re-run the login flow to establish a fresh, valid Google session.","Clear stale Google cookies and log in again.","Confirm you can open notebooklm.google.com in the same browser profile and see your notebooks.","If the account chip exists but the name is unparseable, check for NotebookLM UI changes affecting the probe selector."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await cmd();\n} catch (e) {\n  if (String(e.message).includes('redirected to Google sign-in') || e.name === 'AuthRequiredError') {\n    await login('notebooklm');\n    return cmd();\n  }\n  throw e;\n}","preventionTips":["Re-login when cookies age out; presence of SID/SAPISID doesn't guarantee validity.","Confirm notebooklm.google.com loads correctly in the profile before automating.","Handle AuthRequiredError as a recoverable condition by triggering the login flow."],"tags":["auth","google-sso","redirect","notebooklm"],"backgroundTag":"auth-redirect-to-login","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}