Asking additionnal info after task 2 (res: LoginEnterAlternateIdentifierSubtask) · Issue #9 · sekai-soft/nitter · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
...
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
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
The code I added to circumvent this issue (ie added a task to handle subtask_id : "LoginEnterAlternateIdentifierSubtask")
The text was updated successfully, but these errors were encountered: