8000 Asking additionnal info after task 2 (res: LoginEnterAlternateIdentifierSubtask) · Issue #9 · sekai-soft/nitter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Asking additionnal info after task 2 (res: LoginEnterAlternateIdentifierSubtask) #9

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

Open
FellowNico opened this issue Jan 7, 2025 · 1 comment

Comments

@FellowNico
Copy link
FellowNico commented Jan 7, 2025

After relaunching my docker-compose I ended up having an issue, I investigated and discovered an unhandled case after checking the logs of the tasks (in auth.py)

It seems like there is an additionnal step sometimes when there is a suspicious activity detected.

Here are the logs

nitter  | web    | DEBUG:urllib3.connectionpool:https://api.twitter.com:443 "POST /1.1/onboarding/task.json?flow_name=login&api_version=1&known_device_token=&sim_country_code=us HTTP/11" 200 599
nitter  | web    | DEBUG:root:task1 res={'flow_token': 'XXXXXXX', 'status': 'success', 'subtasks': [{'subtask_id': 'LoginEnterUserIdentifier', 'enter_text': {'primary_text': {'text': 'Pour commencer, entrez votre numéro de téléphone, votre adresse email ou votre @nomdutilisateur', 'entities': []}, 'hint_text': "Numéro de téléphone, adresse email ou nom d'utilisateur", 'multiline': False, 'auto_capitalization_type': 'none', 'auto_correction_enabled': False, 'os_content_type': 'username', 'keyboard_type': 'text', 'next_link': {'link_type': 'task', 'link_id': 'next_link', 'label': 'Suivant'}, 'skip_link': {'link_type': 'subtask', 'link_id': 'forget_password', 'label': 'Mot de passe oublié\xa0?', 'subtask_id': 'RedirectToPasswordReset'}}, 'subtask_back_navigation': 'cancel_flow'}, {'subtask_id': 'RedirectToPasswordReset', 'open_link': {'link': {'link_type': 'deep_link_and_abort', 'link_id': 'password_reset_deep_link', 'url': 'twitter://onboarding/task?flow_name=password_reset&input_flow_data=%7B%22requested_variant%22%3A%22eyJwbGF0Zm9ybSI6IkFuZHJvaWQifQ%3D%3D%22%7D'}}}]}
nitter  | web    | DEBUG:urllib3.connectionpool:https://api.twitter.com:443 "POST /1.1/onboarding/task.json HTTP/11" 200 496
nitter  | web    | DEBUG:root:task2 res={'flow_token': 'XXXXXXX', 'status': 'success', 'subtasks': [{'subtask_id': 'LoginEnterAlternateIdentifierSubtask', 'enter_text': {'primary_text': {'text': "Entrez votre adresse email ou votre nom d'utilisateur.", 'entities': []}, 'secondary_text': {'text': "Nous avons détecté une activité de connexion inhabituelle sur votre compte. Afin de garantir la sécurité de celui-ci, veuillez entrer votre numéro de téléphone ou votre nom d'utilisateur pour confirmer qu'il s'agit bien de vous.", 'entities': []}, 'hint_text': "Numéro de téléphone ou nom d'utilisateur", 'multiline': False, 'auto_capitalization_type': 'none', 'auto_correction_enabled': False, 'keyboard_type': 'text', 'next_link': {'link_type': 'task', 'link_id': 'next_link', 'label': 'Suivant'}}, 'subtask_back_navigation': 'cancel_flow'}]}
nitter  | web    | DEBUG:urllib3.connectionpool:https://api.twitter.com:443 "POST /1.1/onboarding/task.json HTTP/11" 400 174
nitter  | web    | DEBUG:root:task3 res={'errors': [{'code': 366, 'message': "Required input 'LoginEnterAlternateIdentifierSubtask' not provided. XXXXXXX"}]}
nitter  | web    | Failed authentication for any account. Did you enter the right username/password? Please rerun with environment variable DEBUG=1 for debugging, e.g. uncomment the DEBUG=1 in docker-compose.yml file.
nitter  | web    | Exited with code 1
nitter  | nginx  | Interrupting...
nitter  | nginx  | Exited with code 0

The code I added to circumvent this issue (ie added a task to handle subtask_id : "LoginEnterAlternateIdentifierSubtask")

...

    session.headers['att'] = task1.headers.get('att')
    task2 = session.post('https://api.twitter.com/1.1/onboarding/task.json', 
        json={
            "flow_token": task1.json().get('flow_token'),
            "subtask_inputs": [{
                    "enter_text": {
                        "suggestion_id": None,
                        "text": username,
                        "link": "next_link"
                    },
                    "subtask_id": "LoginEnterUserIdentifier"
                }
            ]
        },
        headers=twitter_header
    )
    logging.debug("task2 res=" + str(task2.json()))

    task2bis = None
    potential_suspect_activity_detected = task2.json().get('subtasks', [])
    if potential_suspect_activity_detected:
        if potential_suspect_activity_detected[0]['subtask_id'] == 'LoginEnterAlternateIdentifierSubtask':
            task2bis = session.post('https://api.twitter.com/1.1/onboarding/task.json', 
                json={
                    "flow_token": task2.json().get('flow_token'),
                    "subtask_inputs": [{
                            "enter_text": {
                                "suggestion_id": None,
                                "text": pseudo,
                                "link": "next_link"
                            },
                            "subtask_id": "LoginEnterAlternateIdentifierSubtask"
                        }
                    ]
                },
                headers=twitter_header
            )
    
    if task2bis:
        flow_token_previous_task = task2bis.json().get('flow_token')
    else:
        flow_token_previous_task = task2.json().get('flow_token')

    task3 = session.post('https://api.twitter.com/1.1/onboarding/task.json', 
        json={
            "flow_token": flow_token_previous_task,
            "subtask_inputs": [{
                    "enter_password": {
                        "password": password,
                        "link": "next_link"
                    },
                    "subtask_id": "LoginEnterPassword"
                }
            ],
        },
        headers=twitter_header
    )
    logging.debug("task3 res=" + str(task3.json()))

    for t3_subtask in task3.json().get('subtasks', []):
        if "open_account" in t3_subtask:
            return t3_subtask["open_account"]
        elif "enter_text" in t3_subtask:
            response_text = t3_subtask["enter_text"]["hint_text"]
            print(f"Requested '{response_text}'")
            task4 = session.post(
                "https://api.twitter.com/1.1/onboarding/task.json",
                json={
                    "flow_token": task3.json().get("flow_token"),
                    "subtask_inputs": [
                        {
                            "enter_text": {
                                "suggestion_id": None,
                                "text": mfa_code,
                                "link": "next_link",
                            },
                            # was previously LoginAcid
                            "subtask_id": "LoginTwoFactorAuthChallenge",
                        }
                    ],
                },
                headers=twitter_header,
            ).json()
            for t4_subtask in task4.get("subtasks", []):
                if "open_account" in t4_subtask:
                    return t4_subtask["open_account"]

    return None


...


if __name__ == "__main__":

...

    twitter_credentials_file = os.getenv("TWITTER_CREDENTIALS_FILE", None)
    pseudo = os.getenv("TWITTER_PSEUDO", None)
    username = os.getenv("TWITTER_USERNAME", None)
    password = os.getenv("TWITTER_PASSWORD", None)

    if not twitter_credentials_file and not (username and password):
        print("Please set environment variable TWITTER_CREDENTIALS_FILE, or both TWITTER_USERNAME and TWITTER_PASSWORD")
        sys.exit(1)

    twitter_credentials = []
    if twitter_credentials_file:
        with open(twitter_credentials_file, "r") as f:
            twitter_credentials = json.loads(f.read())
    else:
        mfa_code = os.getenv("TWITTER_MFA_CODE", None)
        twitter_credentials = [{"pseudo": pseudo, "username": username, "password": password, "mfa_code": mfa_code}]

    auth_results = []
    for credential in twitter_credentials:
        pseudo = credential['pseudo']
        username = credential["username"]
        password = credential["password"]
        mfa_code = credential.get("mfa_code", None)
        auth_result = auth(pseudo, username, password, mfa_code)
        auth_results.append(auth_result)

...

@KTachibanaM
Copy link

What is pseudo being input here?

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

2 participants
0