-
-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
two errors, one message is : status: 400, message: "{"errors":[{"code":399,"message":"Incorrect. Please try again. #276
Comments
remove two-factor authentication method |
1 similar comment
remove two-factor authentication method |
How can I do it? Thank you |
I fixed it like this: For 2FA, I created my own class and rewrote the login function: import pyotp
from twikit import Client
from twikit.utils import (
Flow,
find_dict,
)
from twikit.errors import TwitterException
class CustomClient(Client):
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@example.com',
... 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'
}
})
if flow.task_id == 'DenyLoginSubtask':
raise TwitterException(flow.response['subtasks'][0]['cta']['secondary_text']['text'])
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()
print(totp_code)
await flow.execute_task({
'subtask_id': 'LoginTwoFactorAuthChallenge',
'enter_text': {
'text': totp_code,
'link': 'next_link'
}
})
return flow.response |
I am getting:
Without using 2FA. Anyway to fix this? edit: fixed by updating httpx library |
Interesting! What was the version before and the one after? |
Not sure exactly but the version I had the asyncclient wasn't expecting the proxy parameter which probably caused the error. |
by any case, i got this error. Anyone knows something? |
WHen You have this, you have to wait 15 min to connect again. |
status: 400, message: "{"errors":[{"code":398,"message":"We were unable to confirm you're human. Please try again. g;173888669791909171:-1738886698120:ib5EZSlPHZcwmRcX4Tjn3fhI:5"}]}" |
the first error is that login was blocked, and I try again after a while ,the problem seems to be solved
by the way , my proxy is 'https://127.0.0.1:7897' ,is that fine ?
then the second one was happened,error message was here:
and I just want to search something on x:
can you help me @d60 thx
The text was updated successfully, but these errors were encountered: