Giter Club home page Giter Club logo

ValueError: Failed to parse SNlM0e nonce value from the response. Refresh the Gemini web page or access Gemini in a new incognito browser to resend cookies. If issue continues, export browser cookies, set manually. See auth section 3. about gemini-api HOT 31 OPEN

dsdanielpark avatar dsdanielpark commented on May 29, 2024 1
ValueError: Failed to parse SNlM0e nonce value from the response. Refresh the Gemini web page or access Gemini in a new incognito browser to resend cookies. If issue continues, export browser cookies, set manually. See auth section 3.

from gemini-api.

Comments (31)

versatile712 avatar versatile712 commented on May 29, 2024 2

same

from gemini-api.

versatile712 avatar versatile712 commented on May 29, 2024 2

Thanks for your reply. I tried all the codes you provided, and even when I add cookies manaully, the error still exsits. I think it may have nothing to do with automated cookie collection.

from gemini-api.

dsdanielpark avatar dsdanielpark commented on May 29, 2024 2

versatile712

Realted this issue #14.

I have a cookie set that works on one laptop for nearly a month, but not on another, only returning empty responses. It might need more handling related to RotateCookie and exceptions, but I'm too busy with important schedules to spend much time on it.

Please share any solutions you find. I couldn't capture the nonce value with auto cookie but had no issues otherwise.

It might be necessary to reset all data through logins and logouts in different environments and properly define it using the ExportCookie extension.

Once I'm free, I plan to experiment with various accounts to find a solution.

from gemini-api.

versatile712 avatar versatile712 commented on May 29, 2024 1

thanks, but a new problem occured.

ValueError                                Traceback (most recent call last)
Cell In[6], [line 2](vscode-notebook-cell:?execution_count=6&line=2)
      [1](vscode-notebook-cell:?execution_count=6&line=1) from gemini import Gemini
----> [2](vscode-notebook-cell:?execution_count=6&line=2) GeminiClient = Gemini(auto_cookies=True)
      [3](vscode-notebook-cell:?execution_count=6&line=3) # GeminiClient = Gemini(auto_cookies=True, target_cookies = ["__Secure-1PSID", "__Secure-1PSIDTS"]) # Can select cookies.
      [4](vscode-notebook-cell:?execution_count=6&line=4) response = GeminiClient.generate_content("Hello, Gemini. What's the weather like in Seoul today?")

File [c:\Users\user\anaconda3\envs\geminiapi\lib\site-packages\gemini\core.py:71](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:71), in Gemini.__init__(self, session, cookies, cookie_fp, auto_cookies, target_cookies, timeout, proxies)
     [69](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:69) self.proxies = proxies or {}
     [70](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:70) self.timeout = timeout
---> [71](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:71) self.session = session or self._initialize_session()
     [72](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:72) self.base_url: str = URLs.BASE_URL.value
     [73](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:73) self.parser = ResponseParser(cookies=self.cookies)

File [c:\Users\user\anaconda3\envs\geminiapi\lib\site-packages\gemini\core.py:114](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:114), in Gemini._initialize_session(self)
    [111](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:111) elif self.auto_cookies == True:
    [112](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:112)     self._set_cookies_automatically()
--> [114](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:114) self._set_sid_and_nonce()
    [116](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:116) return session

File [c:\Users\user\anaconda3\envs\geminiapi\lib\site-packages\gemini\core.py:162](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:162), in Gemini._set_sid_and_nonce(self)
    [160](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:160)     raise ConnectionError(f"Request failed: {e}")
    [161](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:161) except ValueError as e:
--> [162](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:162)     raise e  # Re-raise the exception after it's caught
...
    [160](file:///C:/Users/user/anaconda3/envs/geminiapi/lib/site-packages/gemini/core.py:160)     raise ConnectionError(f"Request failed: {e}")

ValueError: Failed to parse SNlM0e nonce value from the response.
Refresh the Gemini web page or access Gemini in a new incognito browser to resend cookies. 
If issue continues, export browser cookies, set manually. See auth section 3.

from gemini-api.

dsdanielpark avatar dsdanielpark commented on May 29, 2024 1
  • Cookie behavior may vary based on location and Google account settings. Try cookies beyond the next set.
  • However, automated cookie collection requires further experimentation.
  • Even valid cookies may not work on different servers. Removing all accounts synced with Chrome and trying a new account is advised.
  • If the issue persists, refer to section 3 at Gemini API Authentication for instructions on re-entering cookie values. Note, even valid cookies may fail depending on the server, PC, or account sync status. Experiment with different approaches.

Firstly, try this codes as sequencially:

from gemini import Gemini

GeminiClient = Gemini(auto_cookies=True)

GeminiClient = Gemini(auto_cookies=True, target_cookies = ["__Secure-1PSIDCC"]) 

GeminiClient = Gemini(auto_cookies=True, target_cookies = ["__Secure-1PSID", "__Secure-1PSIDTS"]) 

GeminiClient = Gemini(auto_cookies=True, target_cookies = ["__Secure-1PSIDCC", " __Secure-1PSID", "__Secure-1PSIDTS", "NID"]) 

response = GeminiClient.generate_content("Hello, Gemini. What's the weather like in Seoul today?")
print(response.payload)

from gemini-api.

OlegRuban-ai avatar OlegRuban-ai commented on May 29, 2024 1

@dsdanielpark

Hello! Is it possible to use the automatic collection option on a remote server without GUI?

from gemini-api.

dsdanielpark avatar dsdanielpark commented on May 29, 2024 1

Usercodersystem

This is what I plan to fix. I will check RotateCookie endpoint!

I have importanct interview tomorrow! Thus, I will fix that issue until next weekend. Try to check this code https://github.com/dsdanielpark/Gemini-API?tab=readme-ov-file Reqid may not be useful.

from gemini-api.

dsdanielpark avatar dsdanielpark commented on May 29, 2024

Hot fixed this issue at v2.3.0.

Try to use version over 2.3.0

pip install python-gemini-api==2.2.0

or

pip install -q -U python-gemini-api

from gemini-api.

Usercodersystem avatar Usercodersystem commented on May 29, 2024

Very thanks

from gemini-api.

Usercodersystem avatar Usercodersystem commented on May 29, 2024

Problem Fixed but new Problem is shown 😑🤣

ValueError: Failed to parse SNlM0e nonce value from the response.
Refresh the Gemini web page or access Gemini in a new incognito browser to resend cookies.
If issue continues, export browser cookies, set manually. See auth section 3.

from gemini-api.

Usercodersystem avatar Usercodersystem commented on May 29, 2024

OK very thanks for answering me:)

from gemini-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.