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

Getting the token of Air Purifier Pro v7 #461

Closed
swiergot opened this issue Jan 20, 2019 · 8 comments
Closed

Getting the token of Air Purifier Pro v7 #461

swiergot opened this issue Jan 20, 2019 · 8 comments
Labels

Comments

@swiergot
Copy link
Contributor

Hi,

I've been trying to obtain the token of my air purifier. I want to avoid tricks with the Mi Home app and backups.

Here is what I did. I reset wi-fi on the air purifier, then I connected to its network and "mirobo discover --handshake 1". It displayed the token. I was even able to show status of the device. Then I configured it in the Mi Home app. And the token stopped working ("miio.exceptions.DeviceException: Got checksum error which indicates use of an invalid token. Please check your token!")...

So I reset wi-fi again and got the token (a different one this time, probably normal). Instead of adding the device in the Mi Home app, I ran "mirobo configure-wifi". The air purifier connected to my home network, but the token stopped working again.

I'm confused. Does the token change after pairing the device?

Thanks.

Take care,
Jarek

@rytilahti
Copy link
Owner

Yes, the token gets changed during provisioning, you have to extract it from the backups: https://python-miio.readthedocs.io/en/latest/discovery.html#tokens-from-backups

@swiergot
Copy link
Contributor Author

Too bad. I've found this:

https://github.com/aholstenson/miio/blob/master/docs/management.md#getting-the-token-when-using-the-mi-home-app

Which suggests what I planned was doable but clearly it's not (or I'm doing something wrong).

@swiergot
Copy link
Contributor Author

Just one more question. When I use "mirobo configure-wifi", why won't it show the changed token?

@rytilahti
Copy link
Owner

Unfortunately the device does not report the token back, and there is no known way to request it afterwards either. This is all device dependent, so perhaps it does not reset the token on all devices (or maybe they "fixed" that, e.g., the yeelight bedside lamp did not reset the token until recent firmware upgrades).

The configure-wifi is implemented mostly for completeness, maybe it should be documented somewhere that it is only usable for changing the used network after the device has been already provisioned. Feel free to create a PR for documentation if you like :-)

@swiergot
Copy link
Contributor Author

swiergot commented Jan 21, 2019

I found this yesterday:

https://www.home-assistant.io/components/vacuum.xiaomi_miio/#retrieving-the-access-token

It appears they forgot to disable debug in 5.4.49 release because 5.4.50 (currently on Google Play) will not produce any logs. I downgraded to 5.4.49 and the logs were there, with the token inside :) Much, much easier than playing with backups.

I will post a PR later today.

@syssi
Copy link
Collaborator

syssi commented Jun 6, 2019

This issue is solved and can be closed, right?

@swiergot
Copy link
Contributor Author

swiergot commented Jun 6, 2019

Yes.

@swiergot swiergot closed this as completed Jun 6, 2019
@ismailAtaman
Copy link

Hey,

Have been struggling with tokens myself, found this tool that extracts all token and device information form Xiaomi Cloud very easily without the need to dig up SQLLite DBs or encryption. Thought would share here as well
https://github.com/PiotrMachowski/Xiaomi-cloud-tokens-extractor

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

No branches or pull requests

4 participants