twikit icon indicating copy to clipboard operation
twikit copied to clipboard

Cookie login issue

Open ghost opened this issue 1 year ago • 2 comments

I have an issue: when I login without cookies, I can invoke await client.search_tweet without problem, but when I log in with cookie, when I invoke await client.search_tweet I receive the following error: twikit.errors.Unauthorized: status: 401, message: "{"errors":[{"message":"Could not authenticate you","code":32}]} What can I do to search logging with cookies?

Here is a piece of my code:

async def authentification(self):
        await self._client.login(
            auth_info_1=str(self.username), auth_info_2=self.email, password=str(self._password)
        )
        self._client.save_cookies(os.path.join(self._config_path, "login_cookies.json"))
        print("Logged in and saved cookies!")
        return self._client


    def cookie_login(self, cookies_path):
        self._client.load_cookies(cookies_path)
        self._logger.info("Successfully logged in using cookies.")
        return self._client

I just found this : https://github.com/d60/twikit/issues/163#issuecomment-2253068820 on another problem. Creating cookies in this way fix my problem. Is possible to update the creation of the cookie in order to let them work in this way?

ghost avatar Aug 11 '24 18:08 ghost

I got the same error, even with the cookie obtained as mentioned here: https://github.com/d60/twikit/issues/163#issuecomment-2253068820. It only works the first time. Any updates on this?

perfectoodio avatar Nov 22 '24 13:11 perfectoodio

Hey everyone, I think I'm encountering the same issue. Even though I'm copying and pasting the cookies, they keep expiring. Initially, they lasted for a month, then two weeks, and now just a day. I'm now getting the error: {“errors”:[{“message”:”Could not authenticate you”,”code”:32}]}. However, when I log back into my account, I can bypass the issue, but it reoccurs after 24 hours. Does anyone have any insights into this problem?

desktop69 avatar Jan 29 '25 16:01 desktop69