From b96a4a8676bb2169d30f32340a6a55db72c4fb61 Mon Sep 17 00:00:00 2001 From: Teng Lin Date: Wed, 4 Mar 2026 10:45:21 -0500 Subject: [PATCH 1/2] fix(auth): force .google.com cookies during login for regional users UK users have their auth cookies (SID, HSID, etc.) set on .google.co.uk instead of .google.com after login. The notebooklm.google.com API rejects these regional cookies, causing "Authentication expired" errors. After the user completes login, navigate to accounts.google.com to trigger Google's SSO to issue .google.com-scoped cookies, then return to notebooklm.google.com before saving storage state. Uses wait_until="load" instead of "networkidle" since cookies arrive with response headers and networkidle can hang on Google's analytics-heavy pages. Fixes #146 --- src/notebooklm/cli/session.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/notebooklm/cli/session.py b/src/notebooklm/cli/session.py index 7a917830..f0a7ebca 100644 --- a/src/notebooklm/cli/session.py +++ b/src/notebooklm/cli/session.py @@ -221,6 +221,11 @@ def login(storage): input("[Press ENTER when logged in] ") + # Force .google.com cookies for regional users (e.g. UK lands on + # .google.co.uk). Use "load" not "networkidle" to avoid analytics hangs. + page.goto("https://accounts.google.com/", wait_until="load") + page.goto("https://notebooklm.google.com/", wait_until="load") + current_url = page.url if "notebooklm.google.com" not in current_url: console.print(f"[yellow]Warning: Current URL is {current_url}[/yellow]") From ed87c874882b6476115a0c5492bf4fbb1a2c47a3 Mon Sep 17 00:00:00 2001 From: Teng Lin Date: Wed, 11 Mar 2026 19:35:31 -0400 Subject: [PATCH 2/2] refactor(auth): extract login URLs into constants --- src/notebooklm/cli/session.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/notebooklm/cli/session.py b/src/notebooklm/cli/session.py index f0a7ebca..673bcb7a 100644 --- a/src/notebooklm/cli/session.py +++ b/src/notebooklm/cli/session.py @@ -43,6 +43,10 @@ logger = logging.getLogger(__name__) +GOOGLE_ACCOUNTS_URL = "https://accounts.google.com/" +NOTEBOOKLM_URL = "https://notebooklm.google.com/" +NOTEBOOKLM_HOST = "notebooklm.google.com" + def _sync_server_language_to_config() -> None: """Fetch server language setting and persist to local config. @@ -212,7 +216,7 @@ def login(storage): ) page = context.pages[0] if context.pages else context.new_page() - page.goto("https://notebooklm.google.com/") + page.goto(NOTEBOOKLM_URL) console.print("\n[bold green]Instructions:[/bold green]") console.print("1. Complete the Google login in the browser window") @@ -223,11 +227,11 @@ def login(storage): # Force .google.com cookies for regional users (e.g. UK lands on # .google.co.uk). Use "load" not "networkidle" to avoid analytics hangs. - page.goto("https://accounts.google.com/", wait_until="load") - page.goto("https://notebooklm.google.com/", wait_until="load") + page.goto(GOOGLE_ACCOUNTS_URL, wait_until="load") + page.goto(NOTEBOOKLM_URL, wait_until="load") current_url = page.url - if "notebooklm.google.com" not in current_url: + if NOTEBOOKLM_HOST not in current_url: console.print(f"[yellow]Warning: Current URL is {current_url}[/yellow]") if not click.confirm("Save authentication anyway?"): context.close()