You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 12, 2024. It is now read-only.
Updates the instance's cookies attribute with Gemini API tokens, either from environment variables or by extracting them from the browser, based on the auto_cookies flag.
140
-
"""
141
-
iflen(getattr(self, "cookies", {})) >5:
142
-
return
143
-
144
-
ifself.auto_cookies:
145
-
try:
146
-
self._update_cookies_from_browser()
147
-
ifnotself.cookies:
148
-
raiseValueError("No cookies were loaded from the browser.")
149
-
exceptExceptionase:
150
-
raiseException("Failed to extract cookies from browser.") frome
151
-
else:
152
-
print(
153
-
"Cookie loading issue, try setting auto_cookies to True. Restart browser, log out, log in for Gemini Web UI to work. Keep a single browser open."
154
-
)
155
-
try:
156
-
self.auto_cookies=True
157
-
self._update_cookies_from_browser()
158
-
ifnotself.cookies:
159
-
raiseValueError("No cookies were loaded from the browser.")
160
-
exceptExceptionase:
161
-
print(f"Automatic cookie retrieval failed: {e}")
162
-
163
-
ifnotself.cookies:
164
-
raiseException(
165
-
"Gemini cookies must be provided through environment variables or extracted from the browser with auto_cookies enabled."
166
-
)
167
-
168
-
def_update_cookies_from_browser(self) ->dict:
169
-
"""
170
-
Attempts to extract specific Gemini cookies from the cookies stored by web browsers on the current system.
171
-
172
-
This method iterates over a predefined list of supported browsers, attempting to retrieve cookies that match a specific domain (e.g., ".google.com"). If the required cookies are found, they are added to the instance's cookie store. The process supports multiple modern web browsers across different operating systems.
173
-
174
-
The method updates the instance's `cookies` attribute with any found cookies that match the specified criteria.
175
-
176
-
Raises:
177
-
ValueError: If no supported browser is found with the required cookies, or if an essential cookie is missing after attempting retrieval from all supported browsers.
178
-
"""
179
-
180
-
forbrowser_fninSUPPORTED_BROWSERS:
181
-
try:
182
-
print(
183
-
f"Trying to automatically retrieve cookies from {browser_fn} using the browser_cookie3 package."
Updates the instance's cookies attribute with Gemini API tokens, either from environment variables or by extracting them from the browser, based on the auto_cookies flag.
310
+
"""
311
+
iflen(getattr(self, "cookies", {})) >5:
312
+
return
313
+
314
+
ifself.auto_cookies:
315
+
try:
316
+
self._update_cookies_from_browser()
317
+
ifnotself.cookies:
318
+
raiseValueError("No cookies were loaded from the browser.")
319
+
exceptExceptionase:
320
+
raiseException("Failed to extract cookies from browser.") frome
321
+
else:
322
+
print(
323
+
"Cookie loading issue, try setting auto_cookies to True. Restart browser, log out, log in for Gemini Web UI to work. Keep a single browser open."
324
+
)
325
+
try:
326
+
self.auto_cookies=True
327
+
self._update_cookies_from_browser()
328
+
ifnotself.cookies:
329
+
raiseValueError("No cookies were loaded from the browser.")
330
+
exceptExceptionase:
331
+
print(f"Automatic cookie retrieval failed: {e}")
332
+
333
+
ifnotself.cookies:
334
+
raiseException(
335
+
"Gemini cookies must be provided through environment variables or extracted from the browser with auto_cookies enabled."
336
+
)
337
+
338
+
def_update_cookies_from_browser(self) ->dict:
339
+
"""
340
+
Attempts to extract specific Gemini cookies from the cookies stored by web browsers on the current system.
341
+
342
+
This method iterates over a predefined list of supported browsers, attempting to retrieve cookies that match a specific domain (e.g., ".google.com"). If the required cookies are found, they are added to the instance's cookie store. The process supports multiple modern web browsers across different operating systems.
343
+
344
+
The method updates the instance's `cookies` attribute with any found cookies that match the specified criteria.
345
+
346
+
Raises:
347
+
ValueError: If no supported browser is found with the required cookies, or if an essential cookie is missing after attempting retrieval from all supported browsers.
348
+
"""
349
+
350
+
forbrowser_fninSUPPORTED_BROWSERS:
351
+
try:
352
+
print(
353
+
f"Trying to automatically retrieve cookies from {browser_fn} using the browser_cookie3 package."
0 commit comments