dsdanielpark / Bard-API

The unofficial python package that returns response of Google Bard through cookie value.
https://pypi.org/project/bardapi/
MIT License
5.33k stars 529 forks source link

Automatically update rotating cookie #235

Closed szv99 closed 10 months ago

szv99 commented 10 months ago

This code seems to be generating a new auth token

dsdanielpark commented 10 months ago

Apologies for the late greeting. I have been very busy, which has delayed my response. Thank you for your passionate contributions.

After a single token instance, it seems that the 1PSIDTS updates in the exception block. Is there a reason why only this one cookie is updated, and not others??

I'm curious about the use cases where this works. What differences do you see when using this code and when not using it???

I apologize for not being able to conduct normal QA and package version updates due to the lack of time. I would appreciate your response.

I wonder if there's a way to automatically update the entire set of cookies.

In my opinion, it might be impossible to refresh cookies without external permissions (like system permissions for logging out or forced deletion).

szv99 commented 10 months ago

Apologies for the late greeting. I have been very busy, which has delayed my response. Thank you for your passionate contributions.

After a single token instance, it seems that the 1PSIDTS updates in the exception block. Is there a reason why only this one cookie is updated, and not others??

I'm curious about the use cases where this works. What differences do you see when using this code and when not using it???

I apologize for not being able to conduct normal QA and package version updates due to the lack of time. I would appreciate your response.

I wonder if there's a way to automatically update the entire set of cookies.

In my opinion, it might be impossible to refresh cookies without external permissions (like system permissions for logging out or forced deletion).

Hey. I think if you would load the website with specified cookies missing, it would regenerate them.

And as I saw, the only cookie that updates when using Bard is 1PSIDTS and 3PSIDTS, so I thought we can implement refreshing those cookies every x minutes. Also, cookies that were generated by this script are actually working.

Sorry for the chaos I've made in the codebase by this pull request but I was like 2 days without sleep. (reversing vibes lol)

dsdanielpark commented 10 months ago

szv99이

lol :)

I also only slept for 4 hours today, but I'll take another look at the code over the weekend and try to improve it. Haha!

By the way, I'll check during the weekend if this cookie's update can also be applied to other cookie values. In my opinion, it would be great to implement it as a block that automatically updates based on finding the necessary parameters for updating. I'll redesign and update it based on the code you provided. Thanks again!

thekidchad commented 10 months ago

I think we should put a scheduler to refresh the cookie every 15 mns on the same session

dsdanielpark commented 8 months ago

Hi, szv99

I am reaching out to inquire about a question regarding your method.

I am currently reviewing the update_1PSIDTS method that you have created.

However, I couldn't find a specific part for updating "1PSIDTS" individually in your code. Does your code update the entire cookie dictionary without specifying a particular value?

How are you updating "1PSIDTS" without specifying the cookie value?

I would like to update all three cookie values, namely "Secure-1PSID," "Secure-1PSIDCC," and "__Secure-1PSIDCC." Could you kindly advise me on which part of the code I should modify to achieve this?

Additionally, I am curious to know if the current method is functioning correctly.

Thank you for your assistance.

szv99 commented 8 months ago

@dsdanielpark I'm going to take a look at that when I have some free time to work on my AI projects. And, of course, I'll let you know.

dsdanielpark commented 8 months ago

szv99

Thank you.

I will also look into the relevant information and proceed. While Gemini's free API service has started, I'm considering updating this information as the user authentication process is cumbersome. This update may potentially be the last release of the Bard API package, I think.

szv99 commented 8 months ago

@dsdanielpark I had the same thought. Unfortunately, accessing AI Studio requires using a VPN since it's not available in Europe, lol. How about implementing it as another authentication method alongside the existing one?

dsdanielpark commented 8 months ago

szv99

If possible, it would be most reliable to retrieve the cookies through a request, similar to your method.

While updating using the browser_cookie3 and beautifulsoup4 packages is also feasible, it lacks implementations such as clearing existing cookie values, and beautifulsoup4 may have limited functionality compared to the development effort required.

If your method can update even just three cookies or if you're short on time, please let me know, and I will explore how to update them through the request.

Alternatively, if the method doesn't work properly, please also inform me.

I appreciate your input and contributions. Thank you!