summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/needs_auth/Gemini.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-09 18:11:35 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-09 18:11:35 +0100
commitaf204c31cb047436f4e1c36199e15692eb271f20 (patch)
tree809b00081d39e259b1523457840ddf512d05c1a0 /g4f/Provider/needs_auth/Gemini.py
parentUpdate OpenaiChat.py (diff)
downloadgpt4free-af204c31cb047436f4e1c36199e15692eb271f20.tar
gpt4free-af204c31cb047436f4e1c36199e15692eb271f20.tar.gz
gpt4free-af204c31cb047436f4e1c36199e15692eb271f20.tar.bz2
gpt4free-af204c31cb047436f4e1c36199e15692eb271f20.tar.lz
gpt4free-af204c31cb047436f4e1c36199e15692eb271f20.tar.xz
gpt4free-af204c31cb047436f4e1c36199e15692eb271f20.tar.zst
gpt4free-af204c31cb047436f4e1c36199e15692eb271f20.zip
Diffstat (limited to 'g4f/Provider/needs_auth/Gemini.py')
-rw-r--r--g4f/Provider/needs_auth/Gemini.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/g4f/Provider/needs_auth/Gemini.py b/g4f/Provider/needs_auth/Gemini.py
index 402fc02f..cf739a22 100644
--- a/g4f/Provider/needs_auth/Gemini.py
+++ b/g4f/Provider/needs_auth/Gemini.py
@@ -66,6 +66,8 @@ class Gemini(AsyncGeneratorProvider):
prompt = format_prompt(messages)
if not cookies:
+ cookies = get_cookies(".google.com", False, True)
+ if "__Secure-1PSID" not in cookies or "__Secure-1PSIDCC" not in cookies:
driver = None
try:
driver = get_browser(proxy=proxy)
@@ -88,8 +90,6 @@ class Gemini(AsyncGeneratorProvider):
if driver:
driver.close()
- if not cookies:
- cookies = get_cookies(".google.com", False)
if "__Secure-1PSID" not in cookies:
raise MissingAuthError('Missing "__Secure-1PSID" cookie')
@@ -101,6 +101,7 @@ class Gemini(AsyncGeneratorProvider):
) as session:
async with session.get(cls.url, proxy=proxy) as response:
text = await response.text()
+ open("test.html", "w").write(text)
match = re.search(r'SNlM0e\":\"(.*?)\"', text)
if match:
snlm0e = match.group(1)