fix(auth): force .google.com cookies during login for regional users#151
fix(auth): force .google.com cookies during login for regional users#151
Conversation
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
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an authentication issue for regional users by implementing a mechanism to explicitly obtain Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a fix for an authentication issue affecting users in certain regions by forcing the browser to navigate to Google's account and NotebookLM pages after login. This ensures that broadly-scoped .google.com authentication cookies are set. The approach is sound and the implementation is straightforward. My only suggestion is to refactor the hardcoded URLs into module-level constants to improve maintainability and consistency, as these URLs are used in multiple places.
| page.goto("https://accounts.google.com/", wait_until="load") | ||
| page.goto("https://notebooklm.google.com/", wait_until="load") |
There was a problem hiding this comment.
To improve maintainability and avoid magic strings, consider defining these URLs as constants at the module level. This would also allow reusing the NOTEBOOKLM_URL constant, as "https://notebooklm.google.com/" is hardcoded elsewhere in this file (e.g., line 215).
For example, you could add at the top of the file:
ACCOUNTS_GOOGLE_URL = "https://accounts.google.com/"
NOTEBOOKLM_URL = "https://notebooklm.google.com/"
And then use page.goto(ACCOUNTS_GOOGLE_URL, ...) and page.goto(NOTEBOOKLM_URL, ...) here.
Summary
accounts.google.comthen back tonotebooklm.google.comto force Google's SSO to issue.google.com-scoped cookies before saving storage statewait_until="load"(not"networkidle") to avoid hangs on Google's analytics-heavy pagesContext
UK users have their auth cookies (SID, HSID, etc.) set on
.google.co.ukinstead of.google.com. Previous PRs (#24, #34) handled cookie extraction from regional domains, but the SID token value from.google.co.ukis region-scoped and rejected bynotebooklm.google.comserver-side.This fix operates at the login capture phase — forcing
.google.comcookies to exist beforecontext.storage_state()is called. Safe for all other regions (Singapore, Japan, US, etc.) — their cookies are already on.google.com, so the extra navigations are a no-op aside from ~5–10 extra seconds during login.Fixes #146
Test plan
pytest— 1811 passed)ruff format,ruff check,mypyall cleannotebooklm loginand confirming SID lands on.google.com🤖 Generated with Claude Code