Skip to content

Fix 2FA issue #1600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix 2FA issue #1600

wants to merge 1 commit into from

Conversation

paul159321
Copy link

I found that login_step1 was causing repeated 2FA authentication requests, so I skipped it and modified the way to obtain the serviceToken. For me, it's now possible to log in to the account normally.

@AlexxIT AlexxIT self-assigned this Apr 25, 2025
@AlexxIT
Copy link
Owner

AlexxIT commented Apr 25, 2025

Thanks! I needs to check this.

@zcoo999
Copy link

zcoo999 commented Apr 27, 2025

I found that login_step1 was causing repeated 2FA authentication requests, so I skipped it and modified the way to obtain the serviceToken. For me, it's now possible to log in to the account normally.

Hello! Thank you for the code modifications. I wanted to ask if I can simply overwrite the original file with your modified xiaomi_cloud.py file for it to work properly?

@paul159321
Copy link
Author

I found that login_step1 was causing repeated 2FA authentication requests, so I skipped it and modified the way to obtain the serviceToken. For me, it's now possible to log in to the account normally.

Hello! Thank you for the code modifications. I wanted to ask if I can simply overwrite the original file with your modified xiaomi_cloud.py file for it to work properly?

Yes.After you overwrite the file,you need to restart your homeassistant.

@zcoo999
Copy link

zcoo999 commented Apr 27, 2025

I found that login_step1 was causing repeated 2FA authentication requests, so I skipped it and modified the way to obtain the serviceToken. For me, it's now possible to log in to the account normally.

Hello! Thank you for the code modifications. I wanted to ask if I can simply overwrite the original file with your modified xiaomi_cloud.py file for it to work properly?

Yes.After you overwrite the file,you need to restart your homeassistant.

After I overwrote the file and then restarted HAOS, I was able to log into my account normally. However, after successfully logging in, when I tried to add an entry, I didn't see the gateway under my account. Why is this? Do you know the reason?
Thank you once again for your and the author's efforts!

@BXGricenchos
Copy link

image
可以登陆但是没有任何设备

@BXGricenchos
Copy link

image 可以登陆但是没有任何设备

日志记录器: custom_components.xiaomi_gateway3.core.cloud
来源: custom_components/xiaomi_gateway3/core/xiaomi_cloud.py:195
集成: Xiaomi Gateway 3 (文档, 问题)
首次出现: 08:45:15 (3 次总计出现)
上次记录: 08:47:14

Can't request MIoT API /v2/home/device_list_page
Traceback (most recent call last):
File "/config/custom_components/xiaomi_gateway3/core/xiaomi_cloud.py", line 195, in request
resp = json.loads(decrypt_rc4(signed_nonce, resp))
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_gateway3/core/xiaomi_cloud.py", line 284, in decrypt_rc4
return RC4(base64.b64decode(pwd.encode())).init1024().crypt(base64.b64decode(data))
~~~~~~~~~~~~~~~~^^^^^^
File "/usr/local/lib/python3.13/base64.py", line 88, in b64decode
return binascii.a2b_base64(s, strict_mode=validate)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
binascii.Error: Invalid base64-encoded string: number of data characters (21) cannot be 1 more than a multiple of 4

@zcoo999
Copy link

zcoo999 commented Apr 30, 2025

Thanks! I needs to check this.

Hello 👋
First of all, thank you for your continued work on this project! 🙌

I noticed that the hass-xiaomi-miot project has addressed Xiaomi account login issues in their recent PR #2429, specifically through updates to the xiaomi_cloud.py implementation.

Would you be open to incorporating similar fixes here? I'd be happy to help draft a PR if this approach aligns with the project's direction.Thanks again! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants