Untitled
unknown
plain_text
a year ago
4.5 kB
8
Indexable
Never
def update_2fa(self,password=None): request_url = "https://api.twitter.com/1.1/onboarding/task.json?flow_name=two-factor-auth-app-enrollment" data ={ "input_flow_data": { "flow_context": { "debug_overrides": {}, "start_location": { "location": "settings" } } }, "subtask_versions": { "action_list": 2, "alert_dialog": 1, "app_download_cta": 1, "check_logged_in_account": 1, "choice_selection": 3, "contacts_live_sync_permission_prompt": 0, "cta": 7, "email_verification": 2, "end_flow": 1, "enter_date": 1, "enter_email": 2, "enter_password": 5, "enter_phone": 2, "enter_recaptcha": 1, "enter_text": 5, "enter_username": 2, "generic_urt": 3, "in_app_notification": 1, "interest_picker": 3, "js_instrumentation": 1, "menu_dialog": 1, "notifications_permission_prompt": 2, "open_account": 2, "open_home_timeline": 1, "open_link": 1, "phone_verification": 4, "privacy_options": 1, "security_key": 3, "select_avatar": 4, "select_banner": 2, "settings_list": 7, "show_code": 1, "sign_up": 2, "sign_up_review": 4, "tweet_selection_urt": 1, "update_users": 1, "upload_media": 1, "user_recommendations_list": 4, "user_recommendations_urt": 1, "wait_spinner": 3, "web_modal": 1 } } response = requests.post(url=request_url, headers=self.headers, json=data, cookies=self.cookies, proxies=self.proxy) print(f'response 1: {response.text}') flow_token = response.json()['flow_token'] # print(flow_token) request_url = 'https://api.twitter.com/1.1/onboarding/task.json' data = { "flow_token": flow_token, "subtask_inputs": [ { "subtask_id": "TwoFactorEnrollmentVerifyPasswordSubtask", "enter_password": { "password": password, "link": "next_link" } } ] } response = requests.post(url=request_url, headers=self.headers, json=data, cookies=self.cookies, proxies=self.proxy) print(f'response 2: {response.text}') flow_token = response.json()['flow_token'] request_url = 'https://api.twitter.com/1.1/onboarding/task.json' data = { "flow_token": flow_token, "subtask_inputs": [ { "subtask_id": "TwoFactorEnrollmentAuthenticationAppBeginSubtask", "action_list": { "link": "next_link" } } ] } response = requests.post(url=request_url, headers=self.headers, json=data, cookies=self.cookies, proxies=self.proxy) print(f'response 3: {response.text}') code = response.json()['subtasks'][1]['show_code']['code'] print(code) flow_token = response.json()['flow_token'] otp = pyotp.TOTP(code) otp_code = otp.now() data = { "flow_token": flow_token, "subtask_inputs": [ {"subtask_id": "TwoFactorEnrollmentAuthenticationAppPlainCodeSubtask", "show_code": {"link": "next_link"}}, {"subtask_id": "TwoFactorEnrollmentAuthenticationAppEnterCodeSubtask", "enter_text": {"text": str(otp_code), "link": "next_link"}} ] } request_url = 'https://api.twitter.com/1.1/onboarding/task.json' response = requests.post(url=request_url, headers=self.headers, json=data, cookies=self.cookies, proxies=self.proxy) print(f'response 4: {response.text}') return code