Skip to content
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

[miio] Error loggin to Xiaomi cloud in miio binding - Return code: 0 #13611

Closed
xduseko opened this issue Oct 27, 2022 · 5 comments · Fixed by #13715
Closed

[miio] Error loggin to Xiaomi cloud in miio binding - Return code: 0 #13611

xduseko opened this issue Oct 27, 2022 · 5 comments · Fixed by #13715
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@xduseko
Copy link

xduseko commented Oct 27, 2022

Expected Behavior

Addon logs in to the Xiaomi cloud and retrieves the supported device list.

Current Behavior

Login fails due to unexpected JSON response.

17:38:22.934 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1
17:38:22.984 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1 content response= &&&START&&&{"serviceParam":"{\"checkSafePhone\":false,\"checkSafeAddress\":false,\"lsrp_score\":0.0}","qs":"%3Fsid%3Dxiaomiio%26_json%3Dtrue","code":70016,"description":"登录验证失败","securityStatus":0,"_sign":"0psXfr43eNI0IX6q9Suk3qWbRqU=","sid":"xiaomiio","result":"error","captchaUrl":null,"callback":"https://sts.api.io.mi.com/sts","location":"https://account.xiaomi.com/fe/service/login?_json=true&sid=xiaomiio&qs=%253Fsid%253Dxiaomiio%2526_json%253Dtrue&callback=https%3A%2F%2Fsts.api.io.mi.com%2Fsts&_sign=0psXfr43eNI0IX6q9Suk3qWbRqU%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=","pwd":0,"child":0,"desc":"登录验证失败"}
17:38:22.985 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1 response = HttpContentResponse[HTTP/1.1 200 OK - 760 bytes]
17:38:22.986 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 1 sign = 0psXfr43eNI0IX6q9Suk3qWbRqU=
17:38:22.986 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi Login step 2
17:38:23.047 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi login step 2 response = HttpContentResponse[HTTP/1.1 200 OK - 1014 bytes]
17:38:23.048 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi login step 2 content = &&&START&&&{"notificationUrl":"https://account.xiaomi.com/identity/authStart?sid=passport&context=sMlx600MPFo9smESNZmGDdkmc7e2Z4sYqW81z2t4F3LTh9vz7gf0sNeze4znW9ytwEsqYzgWj0KQ1dl2CDw9Sne6w9qMFRCC6zg0de7L_8y-8xeaHHo6nn35dLNtMQOi8NvYi-RGx0rkivMCpbaPnsFYzDoRliupXK-Ox_r5MWElldDjtKTCY2mxQGinj_eAQdcERP5iV2wG2TqxQdy3AdXAKmfyg6y044u1491wG7tosQAIQriMFmPnhZqBzQjNN8rBmHfnogcvbfxGV0-eqRJTN4XemWcLkO_lLNB0sC26tx4W1rQ2chwK1v5N3DOxJxGofmuXkmq1VqVBqFp7DdVWoy5nGsZnI3CK0WT9cfTQWCXpOeYyJRWGkLP35irZ_X4SukwbSFzQPgu5gMfMPkaSdY0ShZv-BACKoUYW_QQIrf1A0Rc0HReupBQNBbuDcQofNskAvVNLoUOcfV4MSb_s7PGsCh0UP4tk-LGenpNMhMhIT2tcEehGtG8gqgsqIFdYcK7Uwc5KmnGtdRvJTOhuvxUZXSuVB7-aoh86urjJl4n5VMMl7nWUXmZORNXYyfNZ4rhSOWzrBMZiTrQK0JewQkWO3YuXJrGe4h6x33rcSRHGwTPzo2cRpCMg_Xf5xTYe_Fqd-ggqp0NRzZEvntc7y_DRAb8PSo1k_RNf4yWYg7Vg-P4SwhhVUU2nUcQ7FFFJKwG5pooL7UZwbPI5PeU2Up4YEnmrQlQvcmxppnBJNj9PNIna0N8sQomhMl2E&_locale=de_DE","result":"ok","code":0,"captchaUrl":null,"description":"成功","location":"","securityStatus":16,"pwd":0,"child":0,"desc":"成功"}
17:38:23.049 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi login ssecurity =
17:38:23.050 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi login userId =
17:38:23.050 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi login cUserId =
17:38:23.051 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi login passToken =
17:38:23.052 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi login location =
17:38:23.052 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Xiaomi login code = 0
17:38:23.053 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Cookie dump for https://account.xiaomi.com/pass/serviceLoginAuth2
17:38:23.054 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Cookie (.xiaomi.com) : sdkVersion --> accountsdk-18.8.15     (path: /. Removed: false)
17:38:23.055 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Cookie (.xiaomi.com) : deviceId --> cuhdom     (path: /. Removed: false)
17:38:23.055 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Cookie (.xiaomi.com) : uLocale --> de_DE     (path: /. Removed: false)
17:38:23.055 [TRACE] [.miio.internal.cloud.MiCloudConnector] - Cookie (account.xiaomi.com) : pass_ua --> web     (path: /. Removed: false)
17:38:23.056 [INFO ] [.miio.internal.cloud.MiCloudConnector] - Error logging on to Xiaomi cloud (0): Error getting logon location URL. Return code: 0

Steps to Reproduce (for Bugs)

  1. Start fresh openhab instance (3.3.0-alpine)
  2. Install Miio binding addon
  3. Enter Xiaomi cloud email and password to the addon configuration. Also set country to "cn" (I have a device that is supported only in cn region).
  4. Try to add a new thing from Miio binding
  5. Hit the "Scan" button
  6. Check the openhab log. There will be login error.

Context

It seems to be working from my home PC but not from cloud VPS. It looks like there is some kind of user verification step that is missing in openhab addon.

Unfortunately completing the verification flow using home PC browser doesn't help. Openhab addon is still unable to logon. It could be connected to an unverified IP address or something like that.

Your Environment

  • Version used: openhab:3.3.0-alpine build, Mi IO binding 3.3.0
  • Operating System and version (desktop or mobile, Windows 10, Raspbian Buster, ...): Ubuntu, Oracle cloud VPS, ARM cpu

image

image

image

@xduseko xduseko added the bug An unexpected problem or unintended behavior of an add-on label Oct 27, 2022
@xduseko
Copy link
Author

xduseko commented Oct 27, 2022

I have found a temporary workaround.

  1. Run docker image browserless/chrome on VPS
  2. Tunnel port 3000 to your home PC
  3. Visit http://localhost:3000 (or http://:3000) in your browser
  4. Enter the Xiaomi verification URL and follow steps to verify by your e-mail
  5. Rerun Miio addon scan. Xiaomi cloud should trust the IP of your VPS by now.

@lolodomo
Copy link
Contributor

@marcelrv for information

@marcelrv
Copy link
Contributor

Thanks that is helpful.

From the way you got it to work, my understanding is that you basically logged on from the VPS (using the remote chrome) and basically convinced the Xiaomi cloud that the ip you were logging in from was belonging to you.

I do see these 2 entries in the first response. Don't really know if these are true if the ip is right/validated
"checkSafePhone":false,"checkSafeAddress":false,"

There is also the dreadful code":70016,"description":"登录验证失败 which is a not very descriptive message that authentication failed. (but does not provide a reason why)

Anyway, I'll add a line in the miio problems FAQ pointing to this solution.

marcelrv added a commit to marcelrv/openhab-addons that referenced this issue Nov 14, 2022
* Small change in debug loggin is login issues are expected
* Additional trouble shooting steps in readme
* Fix duplicate name in device list preventing readme maker running
* Catch a json exception in readme maker

close openhab#13611
close openhab#7459


Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
@marcelrv marcelrv assigned xduseko and unassigned xduseko Nov 14, 2022
@marcelrv
Copy link
Contributor

@xduseko see the discussion in #13715
Would you mind if I re-use your screenshots in the miio readme. (I have never seen the screen you have, hence can't reproduce similar screenie)

@xduseko
Copy link
Author

xduseko commented Nov 22, 2022

marcelrv I wouldn't mind.

lolodomo pushed a commit that referenced this issue Nov 29, 2022
* [miio] cloud login issues improvement

* Small change in debug loggin is login issues are expected
* Additional trouble shooting steps in readme
* Fix duplicate name in device list preventing readme maker running
* Catch a json exception in readme maker

close #13611
close #7459

* [miio] fix strange/foreign characters in readme

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
andrasU pushed a commit to andrasU/openhab-addons that referenced this issue Dec 24, 2022
* [miio] cloud login issues improvement

* Small change in debug loggin is login issues are expected
* Additional trouble shooting steps in readme
* Fix duplicate name in device list preventing readme maker running
* Catch a json exception in readme maker

close openhab#13611
close openhab#7459

* [miio] fix strange/foreign characters in readme

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
borazslo pushed a commit to borazslo/openhab-mideaac-addon that referenced this issue Jan 8, 2023
* [miio] cloud login issues improvement

* Small change in debug loggin is login issues are expected
* Additional trouble shooting steps in readme
* Fix duplicate name in device list preventing readme maker running
* Catch a json exception in readme maker

close openhab#13611
close openhab#7459

* [miio] fix strange/foreign characters in readme

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
psmedley pushed a commit to psmedley/openhab-addons that referenced this issue Feb 23, 2023
* [miio] cloud login issues improvement

* Small change in debug loggin is login issues are expected
* Additional trouble shooting steps in readme
* Fix duplicate name in device list preventing readme maker running
* Catch a json exception in readme maker

close openhab#13611
close openhab#7459

* [miio] fix strange/foreign characters in readme

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this issue Feb 28, 2023
* [miio] cloud login issues improvement

* Small change in debug loggin is login issues are expected
* Additional trouble shooting steps in readme
* Fix duplicate name in device list preventing readme maker running
* Catch a json exception in readme maker

close openhab#13611
close openhab#7459

* [miio] fix strange/foreign characters in readme

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
andrasU pushed a commit to andrasU/openhab-addons that referenced this issue Jan 6, 2024
* [miio] cloud login issues improvement

* Small change in debug loggin is login issues are expected
* Additional trouble shooting steps in readme
* Fix duplicate name in device list preventing readme maker running
* Catch a json exception in readme maker

close openhab#13611
close openhab#7459

* [miio] fix strange/foreign characters in readme

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants