-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: preserve auth cookies across Google redirects #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -49,6 +49,7 @@ | |||||||||||||||
| # Includes googleusercontent.com for authenticated media downloads | ||||||||||||||||
| ALLOWED_COOKIE_DOMAINS = { | ||||||||||||||||
| ".google.com", | ||||||||||||||||
| "accounts.google.com", | ||||||||||||||||
| "notebooklm.google.com", | ||||||||||||||||
| ".googleusercontent.com", | ||||||||||||||||
| } | ||||||||||||||||
|
|
@@ -659,15 +660,9 @@ async def fetch_tokens(cookies: dict[str, str]) -> tuple[str, str]: | |||||||||||||||
| ValueError: If tokens cannot be extracted from response | ||||||||||||||||
| """ | ||||||||||||||||
| logger.debug("Fetching CSRF and session tokens from NotebookLM") | ||||||||||||||||
| cookie_header = "; ".join(f"{k}={v}" for k, v in cookies.items()) | ||||||||||||||||
|
|
||||||||||||||||
| async with httpx.AsyncClient() as client: | ||||||||||||||||
| response = await client.get( | ||||||||||||||||
| "https://notebooklm.google.com/", | ||||||||||||||||
| headers={"Cookie": cookie_header}, | ||||||||||||||||
| follow_redirects=True, | ||||||||||||||||
| timeout=30.0, | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| async with httpx.AsyncClient(cookies=cookies, follow_redirects=True, timeout=30.0) as client: | ||||||||||||||||
| response = await client.get("https://notebooklm.google.com/") | ||||||||||||||||
| response.raise_for_status() | ||||||||||||||||
|
|
||||||||||||||||
|
Comment on lines
+664
to
667
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
References
|
||||||||||||||||
| final_url = str(response.url) | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clearing the cookie jar here will discard any session cookies or updates received from the server during previous requests (including the refresh request itself) that haven't been manually synced back to
self.auth.cookies. Sinceself.auth.cookiesis a simple dictionary, it doesn't automatically track changes in thehttpxcookie jar. To maintain session continuity, consider updatingself.auth.cookiesfrom the jar before resetting, or simply updating the jar without clearing it.