GoogleBard icon indicating copy to clipboard operation
GoogleBard copied to clipboard

Request fails without the __Secure-1PSIDTS cookie

Open nerblock opened this issue 1 year ago • 8 comments

The value of __Secure-1PSIDTS (or __Secure-2PSIDTS, __Secure-3PSIDTS, etc, depending on the user number) must be included in the cookie. This is what the cookies variable should look like in order to make a successful request:

let cookies = `__Secure-1PSID=<COOKIE_VALUE>; __Secure-1PSIDTS=<COOKIE_VALUE>`;

When it is not included (as described in the current readme) the request fails with this error:

Error parsing response: make sure you are using the correct cookie, copy the value of "__Secure-1PSID" cookie and set it like this:

new Bard("__Secure-1PSID=<COOKIE_VALUE>")

Also using a US proxy is recommended.

If this error persists, please open an issue on github.
https://github.com/PawanOsman/GoogleBard
file:///C:/Users/user/Source/bard-test/node_modules/googlebard/dist/classes/bard.js:174
        return resData[3];
                      ^

TypeError: Cannot read properties of undefined (reading '3')
    at Bard.ask (file:///C:/Users/user/Source/bard-test/node_modules/googlebard/dist/classes/bard.js:174:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async file:///C:/Users/user/Source/bard-test/index.js:8:16

nerblock avatar Jul 14 '23 02:07 nerblock

I did include those cookies and it worked then after 20 minutes the request fails again. What do you think?

piccolo20 avatar Jul 14 '23 09:07 piccolo20

Those cookies always change per 10mins

piccolo20 avatar Jul 14 '23 11:07 piccolo20

I guess they added this requirement to make programatically calliing the api more difficult.

nerblock avatar Jul 14 '23 11:07 nerblock

Oh sorry about that. My fault keep refreshing my browser page and it generates new value. The code works well now.

piccolo20 avatar Jul 14 '23 14:07 piccolo20

@nerblock thanks for creating this issue, by adding __Secure-1PSIDTS=<COOKIE_VALUE> I was able to make it work. However, I did not try to use __Secure-2PSIDTS or __Secure-3PSIDTS. Any way to generate those cookies programmatically?

hugoroussel avatar Jul 16 '23 22:07 hugoroussel

You can use browser_cookie3. Also check out this issue: https://github.com/dsdanielpark/Bard-API/issues/99

nerblock avatar Jul 17 '23 23:07 nerblock

@nerblock thanks for creating this issue, by adding __Secure-1PSIDTS=<COOKIE_VALUE> I was able to make it work. However, I did not try to use __Secure-2PSIDTS or __Secure-3PSIDTS. Any way to generate those cookies programmatically?

You can get them if you get the success response. The response has Set-Cookie:

piccolo20 avatar Jul 18 '23 04:07 piccolo20

@nerblock Did you find a way to get the __Secure-1PSIDTS cookie programmatically?

sturmenta avatar Nov 14 '23 15:11 sturmenta