twikit icon indicating copy to clipboard operation
twikit copied to clipboard

Required input 'LoginAcid' not provided.

Open CoderMike1 opened this issue 1 year ago • 5 comments

Hi, I got this error while im trying to login?

this is my client self.client = Client(language='en-US',proxy=proxy, 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') twikit.errors.BadRequest: status: 400, message: "{"errors":[{"code":366,"message":"Required input 'LoginAcid' not provided."}]}"

username,email address and password are provided

CoderMike1 avatar Sep 27 '24 06:09 CoderMike1

+1

eastwest-code avatar Oct 11 '24 11:10 eastwest-code

+1

EyalShechtman avatar Oct 11 '24 17:10 EyalShechtman

Have you solved this problem yet? I have encountered the same problem

szsyzx avatar Oct 21 '24 06:10 szsyzx

To resolve this error, the modification to the Client class is required, The code:

if flow.task_id == 'LoginAcid':
    print(find_dict(flow.response, 'secondary_text', find_one=True)[0]['text'])

    await flow.execute_task({
        'subtask_id': 'LoginAcid',
        'enter_text': {
            'text': input('>>> '),
            'link': 'next_link'
        }
    })

is at the end in the login function. I moved the chunk of code just after

if flow.task_id == 'DenyLoginSubtask':
	raise TwitterException(flow.response['subtasks'][0]['cta']['secondary_text']['text'])

and it worked for me. Also I have added the return flow.response in the if flow.task_id == 'LoginAcid' condition as well. So, my complete login function looks like the following:

async def login(
        self,
        *,
        auth_info_1: str,
        auth_info_2: str | None = None,
        password: str,
        totp_secret: str | None = None
    ) -> dict:
        """
        Logs into the account using the specified login information.
        `auth_info_1` and `password` are required parameters.
        `auth_info_2` is optional and can be omitted, but it is
        recommended to provide if available.
        The order in which you specify authentication information
        (auth_info_1 and auth_info_2) is flexible.

        Parameters
        ----------
        auth_info_1 : :class:`str`
            The first piece of authentication information,
            which can be a username, email address, or phone number.
        auth_info_2 : :class:`str`, default=None
            The second piece of authentication information,
            which is optional but recommended to provide.
            It can be a username, email address, or phone number.
        password : :class:`str`
            The password associated with the account.
        totp_secret : :class:`str`
            The TOTP (Time-Based One-Time Password) secret key used for
            two-factor authentication (2FA).

        Examples
        --------
        >>> await client.login(
        ...     auth_info_1='example_user',
        ...     auth_info_2='[email protected]',
        ...     password='00000000'
        ... )
        """
        self.http.cookies.clear()
        guest_token = await self._get_guest_token()

        flow = Flow(self, guest_token)

        await flow.execute_task(params={'flow_name': 'login'}, data={
            'input_flow_data': {
                'flow_context': {
                    'debug_overrides': {},
                    'start_location': {
                        'location': 'splash_screen'
                    }
                }
            },
            '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
            }
        })
        await flow.sso_init('apple')
        await flow.execute_task({
            "subtask_id": "LoginJsInstrumentationSubtask",
            "js_instrumentation": {
                "response": await self._ui_metrix(),
                "link": "next_link"
            }
        })
        await flow.execute_task({
            'subtask_id': 'LoginEnterUserIdentifierSSO',
            'settings_list': {
                'setting_responses': [
                    {
                        'key': 'user_identifier',
                        'response_data': {
                            'text_data': {'result': auth_info_1}
                        }
                    }
                ],
                'link': 'next_link'
            }
        })

        if flow.task_id == 'LoginEnterAlternateIdentifierSubtask':
            await flow.execute_task({
                'subtask_id': 'LoginEnterAlternateIdentifierSubtask',
                'enter_text': {
                    'text': auth_info_2,
                    'link': 'next_link'
                }
            })

        await flow.execute_task({
            'subtask_id': 'LoginEnterPassword',
            'enter_password': {
                'password': password,
                'link': 'next_link'
            }
        })

        if flow.task_id == 'DenyLoginSubtask':
            raise TwitterException(flow.response['subtasks'][0]['cta']['secondary_text']['text'])

        if flow.task_id == 'LoginAcid':
            print(find_dict(flow.response, 'secondary_text', find_one=True)[0]['text'])

            await flow.execute_task({
                'subtask_id': 'LoginAcid',
                'enter_text': {
                    'text': input('>>> '),
                    'link': 'next_link'
                }
            })
            
            return flow.response

        
    
        await flow.execute_task({
            'subtask_id': 'AccountDuplicationCheck',
            'check_logged_in_account': {
                'link': 'AccountDuplicationCheck_false'
            }
        })

        if not flow.response['subtasks']:
            return

        self._user_id = find_dict(flow.response, 'id_str', find_one=True)[0]

        if flow.task_id == 'LoginTwoFactorAuthChallenge':
            if totp_secret is None:
                print(find_dict(flow.response, 'secondary_text', find_one=True)[0]['text'])
                totp_code = input('>>>')
            else:
                totp_code = pyotp.TOTP(totp_secret).now()

            await flow.execute_task({
                'subtask_id': 'LoginTwoFactorAuthChallenge',
                'enter_text': {
                    'text': totp_code,
                    'link': 'next_link'
                }
            })

        return flow.response

gohar262 avatar Oct 27 '24 14:10 gohar262

That didnt work for me:(

EyalShechtman avatar Nov 04 '24 20:11 EyalShechtman