Script to obtain watch or band bluetooth token from Huami servers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
argz eeb7fb66af
Remove rich from readme
3 months ago
.gitignore Style rewrite, fix #40 1 year ago
.travis.yml Replce pylint with pytest 2 years ago
Dockerfile add Dockerfile 2 years ago Rename LICENSE to 2 years ago Remove rich from readme 3 months ago Login error messages (#46) 1 year ago Remove prints from most of the class members 8 months ago
requirements.txt Remove Rich dependency 8 months ago Add license to files (#29) 2 years ago

Huami-token is now hosted on

Get it on Codeberg


Build Status

Script to obtain watch or band bluetooth access token from Huami servers. It will also download AGPS data packs and


To use new versions of Amazfit and Xiaomi watches and bands with Gadgetbridge you need special unique key. Read more here:


  1. Ensure 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.
  2. Pair, sync and update your watch with Amazfit App. Your pairing key will be stored on Huami servers.
  3. Clone this repo: git clone
  4. Install requirements: pip3 install -r requirements.txt


usage: [-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 token

Logging in with Amazfit account

Run script with your credentials: python3 --method amazfit --email --password your_password --bt_keys.

Sample output:

> python3 --method amazfit --email my_email --password password --bt_keys
Getting access token with amazfit login method...
Token: ['UaFHW53RJVYwqXaa7ncPQ']
Logging in...
Logged in! User id: 1234567890
Getting linked wearables...

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

Logged out.

Here the auth_key is the unique pairing key for your watch. The ACT tab shows whether a device is active or not.

Logging in with Xiaomi account

This is a little bit harder to use, since you need to login manually on the Xiaomi web site.

  1. Run script python3 --method xiaomi --bt_keys.
  2. Script will ask you to open Xiaomi login web page.
  3. Login with your credentials there.
  4. If your login is successful, browser will show the error that connection is not secured. On this stage address will look like this:
  5. Copy this address.
  6. Return to script, paste this address and press enter.

Sample output:

> python3 --method xiaomi --bt_keys
Getting access token with xiaomi login method...
Copy this URL to web-browser

and login to your Mi account.

Paste URL after redirection here.
Token: ['ALSG_CLOUDSRV_9B8D87D0EB77C71B45FF73B2266D922B']
Logging in...
Logged in! User id: 3000654321
Getting linked wearables...

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

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

Logged out.

Here the auth_key is the unique pairing key for your watch. The ACT tab 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 download

This 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/--firmware argument. Will work only with -b/--bt_keys argument. You should input the ID of a device, or -1 to 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!


  • Python 3.7.7
  • argparse
  • requests
  • urllib
  • random
  • uuid
  • json
  • shutil


This project is licensed under the MIT License - see the file for details