Open ackness opened 3 months ago
Same here
Traceback (most recent call last):
File "C:\Users\xxx\PycharmProjects\scraper-v2\main.py", line 27, in <module>
asyncio.run(main())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.240.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 664, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\xxx\PycharmProjects\scraper-v2\main.py", line 14, in main
error = await client.login(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\xxx\PycharmProjects\scraper-v2\venv\Lib\site-packages\twikit\client\client.py", line 330, in login
if flow.task_id == 'DenyLoginSubtask':
^^^^^^^^^^^^
File "C:\Users\xxx\PycharmProjects\scraper-v2\venv\Lib\site-packages\twikit\utils.py", line 103, in task_id
return self.response['subtasks'][0]['subtask_id']
~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
yup, X shows the login notification then the error.
changing IP worked a few times then not.
It seems that twitter has implemented a measure against automated logins. Using cookies copied from the browser should still work. Use this method until a workaround is found.
logging in seems to work for some accounts and not others
Can you elaborate on how to do that with the cookies @d60 ? I see the set_cookies
on the client, but that doesnt seem to do anything for me?
client.save_cookies('ookies.json')
client.load_cookies('cookies.json')
this worked for me. But I guess after this you must remove the client.login so it uses the cookies only?
client.save_cookies('ookies.json') client.load_cookies('cookies.json')
this worked for me. But I guess after this you must remove the client.login so it uses the cookies only?
Can you please elaborate on how did you do that? what cookies are you supposed to save? I can see some in my browser - auth_multi, auth_token and many more.
Hi everyone.
I’ve published a version that might fix the subtasks issue though I can’t say it’s fully resolved. Please try it out and let me know if it works for you.
python -m pip uninstall --y twikit
python -m pip install https://github.com/d60/twikit/archive/login_fix.zip
File "/home/xxx/.local/lib/python3.12/site-packages/twikit/client/client.py", line 157, in request raise BadRequest(message, headers=response.headers) twikit.errors.BadRequest: status: 400, message: "{"errors":[{"code":366,"message":"flow name LoginFlow is currently not accessible"}]}"
I found that this error is related to the User-Agent. In my environment, I encountered the error when using a Windows UA, but I was able to log in successfully with a Mac UA. It seems that the valid User-Agent might vary depending on the account.
From version 2.1.2, you can pass user_agent parameter to the client and set the UA freely. Find a valid User-Agent for your environment and configure it accordingly.
Like this:
client = Client(
user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 14_6_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15'
)
i appreciate the help. After all that i'm currently getting
client = Client(
^^^^^^^
File "C:\Users\Duffy\AppData\Roaming\Python\Python311\site-packages\twikit\client\client.py", line 93, in init self.http = AsyncClient(proxy=proxy, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: AsyncClient.init() got an unexpected keyword argument 'user_agent'
@DuffyAdams update twijit to the latest version first.
python -m pip install -U twikit
File "/home/xxx/.local/lib/python3.12/site-packages/twikit/client/client.py", line 157, in request raise BadRequest(message, headers=response.headers) twikit.errors.BadRequest: status: 400, message: "{"errors":[{"code":366,"message":"flow name LoginFlow is currently not accessible"}]}"
I am getting the same error, even after adding the user_agent:
client = Client(
user_agent='Mozilla/5.0 (Macintosh; Intel Mac OS X 14_6_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15',
language='en-US',
proxy=proxy
)
await client.login(
auth_info_1=account.screen_name,
auth_info_2=account.email,
password=account.password
)
Same issue
[Running] python -u "c:\Users\Nikhil\Downloads\twittermonitor.py"
Traceback (most recent call last):
File "c:\Users\Nikhil\Downloads\twittermonitor.py", line 4, in
[Done] exited with code=1 in 1.753 seconds
@caronies update httpx to the latest version
Hello everyone.
If you're still encountering the error flow name LoginFlow is currently not accessible
, try setting the following user agent.
Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion
In my case, any user agent generated by fake_useragent
didn’t work, but for some reason, when I set the user agent, I was able to log in successfully. Please let me know if this works for you.
Hello everyone. If you're still encountering the error
flow name LoginFlow is currently not accessible
, try setting the following user agent.Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion
In my case, any user agent generated byfake_useragent
didn’t work, but for some reason, when I set the user agent, I was able to log in successfully. Please let me know if this works for you.
nope
Hello everyone. If you're still encountering the error
flow name LoginFlow is currently not accessible
, try setting the following user agent.Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion
In my case, any user agent generated byfake_useragent
didn’t work, but for some reason, when I set the user agent, I was able to log in successfully. Please let me know if this works for you.
We've tried this, and bad news for current twitter login flow changes.
The only way to make it passed is to postpone query id from subtasks response to the last stage, till all flows including LoginTwoFactorAuthChallenge
done.
@d60 Would be nice to fix it in time, or should I provide a PR?
It seems like every time I try to use the client.login(), Twitter is detecting a suspicious log in, and prompts me to answer security questions/enter verification code. Is there a fix yet? I can try to help if you got the PR approved.
Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion
Not working on my end.
Hello everyone. If you're still encountering the error
flow name LoginFlow is currently not accessible
, try setting the following user agent.Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion
In my case, any user agent generated byfake_useragent
didn’t work, but for some reason, when I set the user agent, I was able to log in successfully. Please let me know if this works for you.
surprisingly this worked for me..? very strange. I must say, it does seem unstable too
Looks like when access flow.task_id , the response sometimes get [] in subtasks
client.py#L330