__Secure-1PSIDTS #5

Closed
opened 2026-02-13 17:27:37 -06:00 by mirrors · 13 comments
Owner

Originally created by @raymerjacque on GitHub (Feb 25, 2024).

the __Secure-1PSIDTS expires very quickly... is there no way around this ? a script to renew it, or another method of authentication ? another cookie or token that can be used ?

some google account dont even show "__Secure-1PSIDTS" its not available in F12 or cookie editor, what to do in such cases ?

Originally created by @raymerjacque on GitHub (Feb 25, 2024). the __Secure-1PSIDTS expires very quickly... is there no way around this ? a script to renew it, or another method of authentication ? another cookie or token that can be used ? some google account dont even show "__Secure-1PSIDTS" its not available in F12 or cookie editor, what to do in such cases ?
mirrors 2026-02-13 17:27:37 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@HanaokaYuzu commented on GitHub (Feb 25, 2024):

As mentioned in readme, the best workaround is to use a separate google account.

github.com/HanaokaYuzu/Gemini-API@3341fd2e00/README.md (L29)

@HanaokaYuzu commented on GitHub (Feb 25, 2024): As mentioned in readme, the best workaround is to use a separate google account. > https://github.com/HanaokaYuzu/Gemini-API/blob/3341fd2e0084f705bf81e7f11a79008e9fbd27b5/README.md?plain=1#L29
Author
Owner

@HanaokaYuzu commented on GitHub (Feb 25, 2024):

If there's no "__Secure-1PSIDTS" in your account's cookie list, simply leaving it empty should work. (I believe so, if not just let me know :)

@HanaokaYuzu commented on GitHub (Feb 25, 2024): If there's no "__Secure-1PSIDTS" in your account's cookie list, simply leaving it empty should work. (I believe so, if not just let me know :)
Author
Owner

@raymerjacque commented on GitHub (Feb 25, 2024):

no, leaving the field blank just gives me :

File "/usr/local/lib/python3.10/dist-packages/gemini/client.py", line 124, in init
raise AuthError(
gemini.types.AuthError: Failed to initiate client. SECURE_1PSIDTS could get expired frequently, please make sure cookie values are up to date.

ERROR: Application startup failed. Exiting.

@raymerjacque commented on GitHub (Feb 25, 2024): no, leaving the field blank just gives me : File "/usr/local/lib/python3.10/dist-packages/gemini/client.py", line 124, in init raise AuthError( gemini.types.AuthError: Failed to initiate client. SECURE_1PSIDTS could get expired frequently, please make sure cookie values are up to date. ERROR: Application startup failed. Exiting.
Author
Owner

@HanaokaYuzu commented on GitHub (Feb 26, 2024):

Can you delete line 76 of client.py and try if it works? Sorry that I don't have such an account to test it myself.
github.com/HanaokaYuzu/Gemini-API@3341fd2e00/src/gemini/client.py (L74-L77)
The code after deletion should be:

self.cookies = { "__Secure-1PSID": secure_1psid }

@HanaokaYuzu commented on GitHub (Feb 26, 2024): Can you delete line 76 of client.py and try if it works? Sorry that I don't have such an account to test it myself. https://github.com/HanaokaYuzu/Gemini-API/blob/3341fd2e0084f705bf81e7f11a79008e9fbd27b5/src/gemini/client.py#L74-L77 The code after deletion should be: ` self.cookies = { "__Secure-1PSID": secure_1psid } `
Author
Owner

@satounity commented on GitHub (Feb 26, 2024):

This is a translation, so please excuse my poor English.

I was also bothered by the early deadline.
It expired in about 5-10 minutes.

However, if you close Gemini's screen immediately after retrieving the cookie, the cookie can be used for a long time.
In fact, I have been using it continuously for over a week.

As a procedure
There is no "__Secure-1PSIDTS" after Gemini re-login.
After a while, "__Secure-1PSIDTS" will appear.
(I don't know the conditions under which "__Secure-1PSIDTS" appears, but...)

After getting the values of “__Secure-1PSID” and “__Secure-1PSIDTS”
Close the Gemini screen.
If the Gemini screen is left open, cookies in Python will expire quickly.

@satounity commented on GitHub (Feb 26, 2024): This is a translation, so please excuse my poor English. I was also bothered by the early deadline. It expired in about 5-10 minutes. However, if you close Gemini's screen immediately after retrieving the cookie, the cookie can be used for a long time. In fact, I have been using it continuously for over a week. As a procedure There is no "__Secure-1PSIDTS" after Gemini re-login. After a while, "__Secure-1PSIDTS" will appear. (I don't know the conditions under which "__Secure-1PSIDTS" appears, but...) After getting the values of “__Secure-1PSID” and “__Secure-1PSIDTS” Close the Gemini screen. If the Gemini screen is left open, cookies in Python will expire quickly.
Author
Owner

@HanaokaYuzu commented on GitHub (Feb 26, 2024):

However, if you close Gemini's screen immediately after retrieving the cookie, the cookie can be used for a long time.

You are right. Combined with another separate account it can last even longer (in my own case around 1 month)

As a procedure There is no "__Secure-1PSIDTS" after Gemini re-login. After a while, "__Secure-1PSIDTS" will appear.

I believe this behavior can be different by account. My account has __Secure-1PSIDTS immediately after logging out and re-login.

Btw re-login will force refresh your previous __Secure-1PSID and __Secure-1PSIDTS.

@HanaokaYuzu commented on GitHub (Feb 26, 2024): > However, if you close Gemini's screen immediately after retrieving the cookie, the cookie can be used for a long time. You are right. Combined with another separate account it can last even longer (in my own case around 1 month) > As a procedure There is no "__Secure-1PSIDTS" after Gemini re-login. After a while, "__Secure-1PSIDTS" will appear. I believe this behavior can be different by account. My account has __Secure-1PSIDTS immediately after logging out and re-login. Btw re-login will force refresh your previous __Secure-1PSID and __Secure-1PSIDTS.
Author
Owner

@HanaokaYuzu commented on GitHub (Mar 1, 2024):

@raymerjacque Can you update to the latest version can try again with the account without __Secure-1PSIDTS?

@HanaokaYuzu commented on GitHub (Mar 1, 2024): @raymerjacque Can you update to the latest version can try again with the account without __Secure-1PSIDTS?
Author
Owner

@Ran-Mewo commented on GitHub (Mar 3, 2024):

what I did was go into an incognito tab, login to gemini from there and use those cookies
it's been quite a long time and it still hasn't expired for me

@Ran-Mewo commented on GitHub (Mar 3, 2024): what I did was go into an incognito tab, login to gemini from there and use those cookies it's been quite a long time and it still hasn't expired for me
Author
Owner

@iamyifan commented on GitHub (Mar 23, 2024):

Hey, I had the same issue before.

My solution is that (macOS + Chrome):

  1. Open an incognito tab.
  2. Type Fn-12, and check out the network tab.
  3. Cope the __Secure-1PSID and __Secure-1PSIDTS to the right place. According to other people, __Secure-1PSIDTS may be missing in your cookies, but only using __Secure-1PSID works for me.
    Your code should look like this:
import asyncio
from gemini_webapi import GeminiClient

# Replace "COOKIE VALUE HERE" with your actual cookie values.
# Leave Secure_1PSIDTS empty if it's not available for your account.

# chop off the "__Secure_1PSID=" and ";" at the end
Secure_1PSID = 'g.a0_something_something_076'
# chop off the "__Secure_1PSIDTS=" and ";" at the end
Secure_1PSIDTS = 'sidts-somgthing_somgthing_EAA'

async def main():
    # If browser-cookie3 is installed, simply use `client = GeminiClient()`
    client = GeminiClient(Secure_1PSID, Secure_1PSIDTS, proxies=None)
    await client.init(timeout=30, auto_close=False, close_delay=300, auto_refresh=False)  # I turned auto-refresh off

asyncio.run(main())
  1. Haven't tested how long it can stay connected but It should work fine now : )
@iamyifan commented on GitHub (Mar 23, 2024): Hey, I had the same issue before. My solution is that (macOS + Chrome): 1. Open an incognito tab. 2. Type `Fn-12`, and check out the `network` tab. 3. Cope the `__Secure-1PSID` and `__Secure-1PSIDTS` to the right place. According to other people, `__Secure-1PSIDTS` may be missing in your cookies, but only using `__Secure-1PSID` works for me. Your code should look like this: ``` python import asyncio from gemini_webapi import GeminiClient # Replace "COOKIE VALUE HERE" with your actual cookie values. # Leave Secure_1PSIDTS empty if it's not available for your account. # chop off the "__Secure_1PSID=" and ";" at the end Secure_1PSID = 'g.a0_something_something_076' # chop off the "__Secure_1PSIDTS=" and ";" at the end Secure_1PSIDTS = 'sidts-somgthing_somgthing_EAA' async def main(): # If browser-cookie3 is installed, simply use `client = GeminiClient()` client = GeminiClient(Secure_1PSID, Secure_1PSIDTS, proxies=None) await client.init(timeout=30, auto_close=False, close_delay=300, auto_refresh=False) # I turned auto-refresh off asyncio.run(main()) ``` 4. Haven't tested how long it can stay connected but It should work fine now : )
Author
Owner

@Ryy00 commented on GitHub (Dec 8, 2024):

I see the issue now about 1PSIDTS it's not about that cookie it's because the 1PSID it self when u run the console the issue is 1PSIDTS but its not the real issue is 1PSID and now i already change 1PSID cookie it works perfectly fine dont change the 1PSIDTS just change the 1PSID cookie trust me 🥰

@Ryy00 commented on GitHub (Dec 8, 2024): I see the issue now about 1PSIDTS it's not about that cookie it's because the 1PSID it self when u run the console the issue is 1PSIDTS but its not the real issue is 1PSID and now i already change 1PSID cookie it works perfectly fine dont change the 1PSIDTS just change the 1PSID cookie trust me 🥰
Author
Owner

@akenila commented on GitHub (Mar 20, 2025):

i still get this error gemini_webapi.exceptions.AuthError: Failed to initialize client. SECURE_1PSIDTS could get expired frequently, please make sure cookie values are up to date. (Failed initialization attempts: 0)
even use 1PSIDTS or not, use incognito tab or not, close screen or not
can someone help me?

@akenila commented on GitHub (Mar 20, 2025): i still get this error gemini_webapi.exceptions.AuthError: Failed to initialize client. SECURE_1PSIDTS could get expired frequently, please make sure cookie values are up to date. (Failed initialization attempts: 0) even use 1PSIDTS or not, use incognito tab or not, close screen or not can someone help me?
Author
Owner

@Ryy00 commented on GitHub (Mar 20, 2025):

the issue is 1PSID it self not the secure 1PSIDTS all you need to do is to
change 1PSID

On Thu, Mar 20, 2025 at 5:15 PM akenila @.***> wrote:

i still get this error gemini_webapi.exceptions.AuthError: Failed to
initialize client. SECURE_1PSIDTS could get expired frequently, please make
sure cookie values are up to date. (Failed initialization attempts: 0)
even use 1PSIDTS or not, use incognito tab or not, close screen or not
can someone help me?


Reply to this email directly, view it on GitHub
https://github.com/HanaokaYuzu/Gemini-API/issues/6#issuecomment-2739685699,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/A6EICXPPR5TYTDACY3QZAYD2VKBLTAVCNFSM6AAAAABSISIFCKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMZZGY4DKNRZHE
.
You are receiving this because you commented.Message ID:
@.***>
[image: akenila]akenila left a comment (HanaokaYuzu/Gemini-API#6)
https://github.com/HanaokaYuzu/Gemini-API/issues/6#issuecomment-2739685699

i still get this error gemini_webapi.exceptions.AuthError: Failed to
initialize client. SECURE_1PSIDTS could get expired frequently, please make
sure cookie values are up to date. (Failed initialization attempts: 0)
even use 1PSIDTS or not, use incognito tab or not, close screen or not
can someone help me?


Reply to this email directly, view it on GitHub
https://github.com/HanaokaYuzu/Gemini-API/issues/6#issuecomment-2739685699,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/A6EICXPPR5TYTDACY3QZAYD2VKBLTAVCNFSM6AAAAABSISIFCKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMZZGY4DKNRZHE
.
You are receiving this because you commented.Message ID:
@.***>

@Ryy00 commented on GitHub (Mar 20, 2025): the issue is 1PSID it self not the secure 1PSIDTS all you need to do is to change 1PSID On Thu, Mar 20, 2025 at 5:15 PM akenila ***@***.***> wrote: > i still get this error gemini_webapi.exceptions.AuthError: Failed to > initialize client. SECURE_1PSIDTS could get expired frequently, please make > sure cookie values are up to date. (Failed initialization attempts: 0) > even use 1PSIDTS or not, use incognito tab or not, close screen or not > can someone help me? > > — > Reply to this email directly, view it on GitHub > <https://github.com/HanaokaYuzu/Gemini-API/issues/6#issuecomment-2739685699>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/A6EICXPPR5TYTDACY3QZAYD2VKBLTAVCNFSM6AAAAABSISIFCKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMZZGY4DKNRZHE> > . > You are receiving this because you commented.Message ID: > ***@***.***> > [image: akenila]*akenila* left a comment (HanaokaYuzu/Gemini-API#6) > <https://github.com/HanaokaYuzu/Gemini-API/issues/6#issuecomment-2739685699> > > i still get this error gemini_webapi.exceptions.AuthError: Failed to > initialize client. SECURE_1PSIDTS could get expired frequently, please make > sure cookie values are up to date. (Failed initialization attempts: 0) > even use 1PSIDTS or not, use incognito tab or not, close screen or not > can someone help me? > > — > Reply to this email directly, view it on GitHub > <https://github.com/HanaokaYuzu/Gemini-API/issues/6#issuecomment-2739685699>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/A6EICXPPR5TYTDACY3QZAYD2VKBLTAVCNFSM6AAAAABSISIFCKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMZZGY4DKNRZHE> > . > You are receiving this because you commented.Message ID: > ***@***.***> >
Author
Owner

@glaw1984 commented on GitHub (Jul 10, 2025):

1PSID 本身,

有没有什么解决办法?隐私模式获取到的几分钟就过期了

@glaw1984 commented on GitHub (Jul 10, 2025): > 1PSID 本身, 有没有什么解决办法?隐私模式获取到的几分钟就过期了
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mirrors/Gemini-API#5
No description provided.