Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
fix: get token value
Browse files Browse the repository at this point in the history
  • Loading branch information
dsdanielpark committed Feb 26, 2024
1 parent 8d4cd7d commit d212073
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bardapi/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,19 @@ def _get_snim0e(self) -> str:
Raises:
Exception: If the __Secure-1PSID value is invalid or SNlM0e value is not found in the response.
"""
resp = self.session.get(
"https://gemini.google.com/app", timeout=self.timeout, proxies=self.proxies
response = self.session.get(
"https://gemini.google.com/", timeout=self.timeout, proxies=self.proxies
)
if resp.status_code != 200:
if response.status_code != 200:
raise Exception(
f"Response status code is not 200. Response Status is {resp.status_code}"
f"Response status code is not 200. Response Status is {response.status_code}"
)
snim0e = re.search(r"SNlM0e\":\"(.*?)\"", resp.text)
if not snim0e:
snim0e = re.findall(r'nonce="([^"]+)"', response.text)
if snim0e == None:
raise Exception(
"SNlM0e value not found. Double-check __Secure-1PSID value or pass it as Bard(token='xxxxx')"
"SNlM0e token value not found. Double-check cookies dict value or set 'auto_cookies' parametes as True.\nOccurs due to cookie changes. Re-enter new cookie, restart browser, re-login, or manually refresh cookie."
)
return snim0e.group(1)
return snim0e

def get_answer(
self,
Expand Down

0 comments on commit d212073

Please sign in to comment.