MCPcopy
hub / github.com/PleasePrompto/notebooklm-skill / setup_auth

Method setup_auth

scripts/auth_manager.py:86–158  ·  view source on GitHub ↗

Perform interactive authentication setup Args: headless: Run browser in headless mode (False for login) timeout_minutes: Maximum time to wait for login Returns: True if authentication successful

(self, headless: bool = False, timeout_minutes: int = 10)

Source from the content-addressed store, hash-verified

84 return info
85
86 def setup_auth(self, headless: bool = False, timeout_minutes: int = 10) -> bool:
87 """
88 Perform interactive authentication setup
89
90 Args:
91 headless: Run browser in headless mode (False for login)
92 timeout_minutes: Maximum time to wait for login
93
94 Returns:
95 True if authentication successful
96 """
97 print("🔐 Starting authentication setup...")
98 print(f" Timeout: {timeout_minutes} minutes")
99
100 playwright = None
101 context = None
102
103 try:
104 playwright = sync_playwright().start()
105
106 # Launch using factory
107 context = BrowserFactory.launch_persistent_context(
108 playwright,
109 headless=headless
110 )
111
112 # Navigate to NotebookLM
113 page = context.new_page()
114 page.goto("https://notebooklm.google.com", wait_until="domcontentloaded")
115
116 # Check if already authenticated
117 if "notebooklm.google.com" in page.url and "accounts.google.com" not in page.url:
118 print(" ✅ Already authenticated!")
119 self._save_browser_state(context)
120 return True
121
122 # Wait for manual login
123 print("\n ⏳ Please log in to your Google account...")
124 print(f" ⏱️ Waiting up to {timeout_minutes} minutes for login...")
125
126 try:
127 # Wait for URL to change to NotebookLM (regex ensures it's the actual domain, not a parameter)
128 timeout_ms = int(timeout_minutes * 60 * 1000)
129 page.wait_for_url(re.compile(r"^https://notebooklm\.google\.com/"), timeout=timeout_ms)
130
131 print(f" ✅ Login successful!")
132
133 # Save authentication state
134 self._save_browser_state(context)
135 self._save_auth_info()
136 return True
137
138 except Exception as e:
139 print(f" ❌ Authentication timeout: {e}")
140 return False
141
142 except Exception as e:
143 print(f" ❌ Error: {e}")

Callers 2

re_authMethod · 0.95
mainFunction · 0.95

Calls 4

_save_browser_stateMethod · 0.95
_save_auth_infoMethod · 0.95
closeMethod · 0.80

Tested by

no test coverage detected