Package: huami-token
Huami-token is now hosted oncodeberg.org.Huami-tokenScript to obtain watch or band bluetooth access token from Huami servers.
It will also download AGPS data packscep_alm_pak.zipandcep_7days.zip.AboutTo use new versions of Amazfit and Xiaomi watches and bands with Gadgetbridge you need special unique key.
Read more here:https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Huami-Server-Pairing.CommunityIf you would like to get in touchMatrix:#huami-token:matrix.orgPreparationEnsure that you login in Amazfit App with Amazfit or Xiaomi account --
because only this login methods are supported. If not, create new Amazfit account
with e-mail and password.Pair, sync and update your watch with Amazfit App. Your pairing key will be stored on
Huami servers.pip3 install huami_tokenUse like this:python3 -m huami_token ...Usageusage: huami_token.py [-h] -m {amazfit,xiaomi} [-e EMAIL] [-p PASSWORD] [-b]
                      [-g] [-a] [-n]

Obtain Bluetooth Auth key from Amazfit servers and download AGPS data.

optional arguments:
  -h, --help            show this help message and exit
  -m {amazfit,xiaomi}, --method {amazfit,xiaomi}
                        Login method
  -e EMAIL, --email EMAIL
                        Account e-mail address
  -p PASSWORD, --password PASSWORD
                        Account Password
  -b, --bt_keys         Get bluetooth tokens of paired devices
  -g, --gps             Download A-GPS files
  -f, --firmware        Request firmware updates. Works only with -b/--bt_keys
                        argument. Extremely dangerous
  -a, --all             Do everything: get bluetooth tokens, download A-GPS
                        files. But do NOT download firmware updates
  -n, --no_logout       Do not logout, keep active session and display app
                        token and access tokenLogging in with Amazfit accountRun script with your credentials:python3 huami_token.py --method amazfit --email youemail@example.com --password your_password --bt_keys.Sample output:>python3huami_token.py--methodamazfit--emailmy_email--passwordpassword--bt_keys
Gettingaccesstokenwithamazfitloginmethod...
Token:['UaFHW53RJVYwqXaa7ncPQ']Loggingin...
Loggedin!Userid:1234567890Gettinglinkedwearables...

╓───Device0║MAC:AB:CD:EF:12:34:56,active:Yes
║Key:0xa3c10e34e5c14637eea6b9efc06106
╙────────────

Loggedout.Here theauth_keyis the unique pairing key for your watch. TheACTtab shows whether a device is
active or not.Logging in with Xiaomi accountThis is a little bit harder to use, since you need to login manually on the Xiaomi web site.Run scriptpython3 huami_token.py --method xiaomi --bt_keys.Script will ask you to open Xiaomi login web page.https://account.xiaomi.com/oauth2/authorize?skip_confirm=false&client_id=2882303761517383915&pt=0&scope=1+6000+16001+20000&redirect_uri=https%3A%2F%2Fhm.xiaomi.com%2Fwatch.do&_locale=en_US&response_type=codeLogin with your credentials there.If your login is successful, browser will show the error that connection is not secured.
On this stage address will look like this:https://hm.xiaomi.com/watch.do?code=ALSG_CLOUDSRV_9B8D87D0EB77C71B45FF73B2266D922B.Copy this address.Return to script, paste this address and pressenter.Sample output:>python3huami_token.py--methodxiaomi--bt_keys
Gettingaccesstokenwithxiaomiloginmethod...
CopythisURLtoweb-browser

https://account.xiaomi.com/oauth2/authorize?skip_confirm=false&client_id=2882303761517383915&pt=0&scope=1+6000+16001+20000&redirect_uri=https%3A%2F%2Fhm.xiaomi.com%2Fwatch.do&_locale=en_US&response_type=code

andlogintoyourMiaccount.

PasteURLafterredirectionhere.
https://hm.xiaomi.com/watch.do?code=ALSG_CLOUDSRV_9B8D87D0EB77C71B45FF73B2266D922B
Token:['ALSG_CLOUDSRV_9B8D87D0EB77C71B45FF73B2266D922B']Loggingin...
Loggedin!Userid:3000654321Gettinglinkedwearables...

╓───Device0║MAC:12:34:56:AB:CD:EF,active:Yes
║Key:0x3c10e34e5c1463527579996fa83e6d
╙────────────

╓───Device1║MAC:BA:DC:FE:21:43:65,active:No
║Key:0x00
╙────────────

Loggedout.Here theauth_keyis the unique pairing key for your watch. TheACTtab shows whether a device is
active or not.In this example I have two devices: the first one is my Amazfit Bip S watch,
the second one is my Xiaomi Mi Smart Scale.Experimental: updates downloadThis is extremely dangerous: flashing the wrong version can brick your device!
I am not responsible for any of problems that might arise.Can be enabled with-f/--firmwareargument. Will work only with-b/--bt_keysargument.
You should input the ID of a device, or-1to check for all.
Script will try to find updates for the firmware and the font pack for the device from
the table above.Use the downloaded files at your own risk!DependenciesPython 3.7.7argparserequestsurllibrandomuuidjsonshutilLicenseThis project is licensed under the MIT License - see theLICENSE.mdfile for details