d60 / twikit

Twitter API Scraper | Without an API key | Twitter Internal API | Free | Twitter scraper | Twitter Bot

Home Page:https://twikit.readthedocs.io/en/latest/twikit.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Login is not working

ab-muhammad-hamza opened this issue · comments

So I get the following error, it was working fine in the morning. Hope I am not just dumb and I think it is an issue!

  Traceback (most recent call last):
  File "C:\Users\****\OneDrive\Desktop\-----\login\x.py", line 10, in <module>
    client.login(
  File "C:\Python311\Lib\site-packages\twikit\client.py", line 169, in login
    headers = self._base_headers | {
  File "C:\Python311\Lib\site-packages\twikit\client.py", line 112, in _base_headers
    csrf_token = self._get_csrf_token()
  File "C:\Python311\Lib\site-packages\twikit\client.py", line 130, in _get_csrf_token
    return self.http.client.cookies.get('ct0')
  File "C:\Python311\Lib\site-packages\httpx\_models.py", line 1103, in get
    if cookie.name == name:
AttributeError: 'tuple' object has no attribute 'name'

This is the code I used:

from twikit import Client

USERNAME = '----'
EMAIL = '----'
PASSWORD = '----'

client = Client('en-US')

# Login to the service with provided user credentials
client.login(
    auth_info_1=USERNAME ,
    auth_info_2=EMAIL,
    password=PASSWORD
)

client.get_cookies()
client.save_cookies('../sessions/x/cookies.json')

PS: I also tried removing the cookies and just tried login, it is not working and my account works fine on X on same IP

I think it happened because of some other module installed, I've tried in a new environment, it worked!