Skip to content

Login failed: Captcha required but script says credentials wrong. #129

Description

@NedAlex94

I’m running into a login failure that’s misreported by the script. When trying to authenticate, the script reports “invalid login or password,”. But this made no sense, since it had worked the day before.

So I added some debugs in the code, and I got a response from Xiaomi’s server containing "description": "验证码输入错误" and a captchaUrl field. That error means “Captcha input error” in Chinese.

[DEBUG] login_step_2: URL: https://account.xiaomi.com/pass/serviceLoginAuth2

[DEBUG] login_step_2: Fields: {'sid': 'xiaomiio', 'hash': '<redacted>', 'callback': 'https://sts.api.io.mi.com/sts', 'qs': '%3Fsid%3Dxiaomiio%26_json%3Dtrue', 'user': 'XXXXX', '_sign': '0psXfr43eNI0IX6q9Suk3qWbRqU=', '_json': 'true'}

[DEBUG] login_step_2: Response text: &&&START&&&{"qs":"%3Fsid%3Dxiaomiio%26_json%3Dtrue","code":87001,"description":"验证码输入错误","securityStatus":0,"_sign":"0psXfr43eNI0IX6q9Suk3qWbRqU=","sid":"xiaomiio","result":"error","captchaUrl":"/pass/getCode?icodeType=login&0.3094213243055923","callback":"https://sts.api.io.mi.com/sts","location":"","pwd":0,"child":0,"desc":"验证码输入错误"}

[DEBUG] Downloading captcha image from: https://account.xiaomi.com/pass/getCode?icodeType=login&0.3094213243055923

[INFO] Captcha image saved at: C:<redacted>\Local\Temp\tmp5eh0517g.jpg

Enter captcha as shown in the image: <redacted>

So to fix this, I made a function that gets the captcha, and shows it to the user with Pillow, then asks for an input. After that, the script resends the login request with the captcha code included and everything works.

I’ve already patched this in my own code and can submit a pull request if you want. Let me know if you’re interested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions