Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors":[{"code":366,"message":"flow name LoginFlow is currently not accessible"}] #251

Open
theordev opened this issue Nov 7, 2024 · 5 comments

Comments

@theordev
Copy link

theordev commented Nov 7, 2024

Hey !

Just trying this good project on my debian VPS but I got this twikit.errors.BadRequest: status: 400, message: "{"errors":[{"code":366,"message":"flow name LoginFlow is currently not accessible"}]}" on launch.

I have no problem at all on my own computer. Maybe this is the IP of the vps ? My script got the :

USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36'

twitter_client = Client(user_agent=USER_AGENT)

this is the user agent that i use on my real computer when using twitter.

No idea about what to try...

@yskmry
Copy link

yskmry commented Nov 8, 2024

Login flow is unstable. I recommend to use client.load_cookies() or client.set_cookies(). Cookies are from logged in account of owned pc or VPS.
If you use cookies, user-agent is not necessary.

@brownepres
Copy link

There is a newer version which is still in pull requests, but supposedly solved this problem.
pip uninstall twikit
pip install git+https://github.com/mdmrcglu/twikit.git

This library should work

@brownepres
Copy link

And also, some networks of larger corporations (like eduroam in all European schools) block twikit for some reason. Try an other network

@yutarour
Copy link

yutarour commented Nov 21, 2024

A lot of people seem to be having the same problem, so here's the solution. Don't log in using the username and password since it's broken. Just use the cookie. You can use a extension like cookie-editor in order to grab the cookies from the browser. However, some extensions tend to return the cookies in a weird format. The cookies, when being passed to set_cookies() should be in a format of {"key":"value","cookie name","value"}.

Here's my implementation of the post searching example with the cookies I exported using the cookie editor linked above:

from twikit import Client
import asyncio
import json

cookies = []
with open(r"./cookies.json",'r') as file:
    cookies = json.load(file)

cookies_formatted = {}
for cookie in cookies:
    cookies_formatted[cookie["name"]] = cookie["value"]

client = Client("en-US")
async def main():
    client.set_cookies(cookies_formatted)
    tweets = await client.search_tweet("python",product="Top")
    for tweet in tweets:
        print(
            tweet.user.name,
            tweet.text,
            tweet.created_at,
        )
asyncio.run(main())

p.s. Noticed that #239 has a solution as well.

@vegetabo
Copy link

A lot of people seem to be having the same problem, so here's the solution. Don't log in using the username and password since it's broken. Just use the cookie. You can use a extension like cookie-editor in order to grab the cookies from the browser. However, some extensions tend to return the cookies in a weird format. The cookies, when being passed to set_cookies() should be in a format of {"key":"value","cookie name","value"}.

Here's my implementation of the post searching example with the cookies I exported using the cookie editor linked above:

from twikit import Client
import asyncio
import json

cookies = []
with open(r"./cookies.json",'r') as file:
    cookies = json.load(file)

cookies_formatted = {}
for cookie in cookies:
    cookies_formatted[cookie["name"]] = cookie["value"]

client = Client("en-US")
async def main():
    client.set_cookies(cookies_formatted)
    tweets = await client.search_tweet("python",product="Top")
    for tweet in tweets:
        print(
            tweet.user.name,
            tweet.text,
            tweet.created_at,
        )
asyncio.run(main())

p.s. Noticed that #239 has a solution as well.

this work for me, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants