Coder Social home page Coder Social logo

argrento / huami-token Goto Github PK

View Code? Open in Web Editor NEW
410.0 21.0 98.0 46 KB

Script to obtain watch or band bluetooth token from Huami servers

License: MIT License

Python 99.01% Dockerfile 0.99%
amazfit huami xiaomi reverse-engineering python gadgetbridge hacktoberfest

huami-token's People

Contributors

argrento avatar bartmanus avatar lyz-code avatar mohjive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

huami-token's Issues

Mi band 5, problem with retreiving account info

Hi,
I'm trying to get the the auth_key for Mi Band 5 but after pasting the url after the security warning I get a python error although it returns the Token

Token: ['ALSG_CLOUDSRV_693DA83C7C743F209EACB663********'] ( I removed part of the token for security reasons)
Logging in...
Traceback (most recent call last):
  File "huami_token.py", line 265, in <module>
    device.login()
  File "huami_token.py", line 116, in login
    raise ValueError(f"Login error. Error: {login_result['error_code']}")
ValueError: Login error. Error: 0117

I checked the code itself. I'm not sure but is it using the correct url?

Login step for Xiaomi method failing

When running python huami_token.py --method xiaomi --bt_keys and following the instructions in README.md, after the copying and pasting the redirect URL into the terminal, I get the following error:

Traceback (most recent call last):
  File "huami_token.py", line 352, in <module>
    device.login()
  File "huami_token.py", line 141, in login
    raise ValueError(f"Login error. Error: {login_result['error_code']}")
ValueError: Login error. Error: 0117```

If this is an error on my end, I'll be glad to best figure out how to solve this :)

ValueError: Login error. Error: 0117

When I use the command ‘python3 huami_token.py --method xiaomi --bt_keys’,
I have obtained the code and entered it,such as https://hm.xiaomi.com/watch.do?code=C3_XXXXXXXXXXXXXXXX
I make an error, as follows:
ValueError: Login error. Error: 0117
I print return msg,that is: {'error_code': '0117', 'data': {'wechatPhone': None, 'accessToken': 'V3_xxxxxxxxxxxxxxxxx', 'refreshToken': 'R3_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'}}

When I use the command 'python3 huami_token.py --method amazfit --email [email protected] --password xxxx --bt_keys',
I make an error, as follows:
ValueError: Wrong E-mail or Password.Error: ['401']
I print return msg,that is : {'error': ['401'], 'state': ['REDIRECTION'], 'region': ['cn-northwest-1']}

Thanks.

404 in hm.xiaomi.com

I run script with method xiaomi (python huami_token.py --method xiaomi --bt_keys)
Then I authorize by getted link with my Mi Account
Then I get redirected to 404 page (https://hm.xiaomi.com/watch.do?code=KSMOSCLOUDSRV_D049CD1E74*****) (url hidden)
I attempt to paste this to script and get empty result

+-------------------------------------------------------------------------------+
| ID  | ACT |        MAC        |                   auth_key                    |
|-----+-----+-------------------+-----------------------------------------------|
+-------------------------------------------------------------------------------+

Device: Mi Band 4C / Redmi Band
Phone: Redmi Note 10
App for linking mi band to account: Xiaomi Wearable (mi fit don't connect to my device)
And what I see:
I get different user id (is this mi account id?) in script (8703751884) and in mi wear (linked mi account id) (4151544115) but I enter same credentials

Lack of ability to login to amazfit account via google

I've created my Amazfit account using google oauth and now I cannot access it using this tool. Trying to reset the password of my account does not work as this account has no email assigned to it and I cannot find a way to assign one.

Is there any other way I can use this account with this tool? Maybe somebody know a method to set user and password on Amazfit accounts created by oauth?

containerize for easier use

Hi.

Having a Dockerfile allows for quicker setup and isolation of the software for CLI users.

Suggested implementation in PR #23.

Xiaomi login fails

Has the procedure changed at all?

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

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

and login to your Mi account.

Paste URL after redirection here.
https://hm.xiaomi.com/watch.do?code=ALSG_CLOUDSRV_XXXXXXXXXXXXXXXXXXXXXXXXX
Token: ['ALSG_CLOUDSRV_XXXXXXXXXXXXXXXXXXXXXXXXXXXX]
Logging in...
Traceback (most recent call last):
  File "huami_token.py", line 222, in <module>
    device.login()
  File "huami_token.py", line 106, in login
    raise ValueError(f"Login error. Error: {login_result['error_code']}")
ValueError: Login error. Error: 0117

Download new AGPS

Hi, the cep_pak.bin file downloaded by this script, while correct for the Bip, and some older firmwares, doesnt seem to be the file used by Zepp on devices with newer firmwares.(GTS)

Could you investigate and see if there is a new download?

Thanks

No linked wearables

I get the error message mentioned in the title when trying to log in with my Xiaomi account.

The account exists and I can log in with it.

Can you help me further?

Error Log:

Logging in...
Traceback (most recent call last):
  File "/home/user/git/huami-token/huami_token.py", line 353, in <module>
    device.login()
  File "/home/user/git/huami-token/huami_token.py", line 144, in login
    raise ValueError(f"Login error. Error: {error_message}")
ValueError: Login error. Error: 0117. Account not registered.

No luck getting pairing key

None of these methods have come close to working. For example, when I try the xiaomi app way, it never lets me login with the URL supplied by the python code. The other way gives a pile of errors, among which are:

...
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/jay/Programs/miniconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked,
File "/home/jay/Programs/miniconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn)
File "/home/jay/Programs/miniconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
conn.connect()
File "/home/jay/Programs/miniconda3/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
conn = self._new_conn()
File "/home/jay/Programs/miniconda3/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f94c2ed2210>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

....

I first paired my watch to the amazfit app. But then could not login to the amazfit site with those credentials.

Some details:
Amazfit Bip S
Android Phone
Linux desktop using either firefox or brave browsers
Python 3.7.6

UnicodeEncodeError when displaying table

Managed to get to the last stage, but got this error:

...
Logging in...
Logged in! User id: <id>
Getting linked wearables...
Traceback (most recent call last):
  File "huami_token.py", line 227, in <module>
    console.print(table)
  File "/opt/lib/python3.6/site-packages/rich/console.py", line 849, in print
    render(renderable, render_options), self.get_style(style)
  File "/opt/lib/python3.6/site-packages/rich/console.py", line 442, in __exit__
    self._exit_buffer()
  File "/opt/lib/python3.6/site-packages/rich/console.py", line 420, in _exit_buffer
    self._check_buffer()
  File "/opt/lib/python3.6/site-packages/rich/console.py", line 957, in _check_buffer
    self.file.write(text)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-59: ordinal not in range(128)

As a work-around, what I ended up doing was simply adding print(device_keys) just before for device_key in device_keys: and it showed the auth key right before the above traceback. I used the key to connect GadgetBridge to my Miband 4, no problems.

The output didn't seem to have anything weird in it - just the MAC address and hex auth code. So I don't know why console.py couldn't encode the characters. Maybe it was the table border characters?

Unable to start getting AuthKey using Xiaomi account

I use Python 3.7.7 and all dependencies are installed.

C:\Users\RedbeanW\Desktop\Repo\huami-token>python -V
Python 3.7.7

C:\Users\RedbeanW\Desktop\Repo\huami-token>python3 huami_token.py --method xiaomi --bt_keys

C:\Users\RedbeanW\Desktop\Repo\huami-token>pip3 install -r requirements.txt
Requirement already satisfied: requests in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from -r requirements.txt (line 1)) (2.27.1)
Requirement already satisfied: rich in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from -r requirements.txt (line 2)) (10.16.2)
Requirement already satisfied: pytest-pylint==0.18.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from -r requirements.txt (line 3)) (0.18.0)
Requirement already satisfied: pytest-flake8==1.0.6 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from -r requirements.txt (line 4)) (1.0.6)
Requirement already satisfied: toml>=0.7.1 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest-pylint==0.18.0->-r requirements.txt (line 3)) (0.10.2)
Requirement already satisfied: pylint>=2.3.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest-pylint==0.18.0->-r requirements.txt (line 3)) (2.12.2)
Requirement already satisfied: pytest>=5.4 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest-pylint==0.18.0->-r requirements.txt (line 3)) (6.2.5)
Requirement already satisfied: flake8>=3.5 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest-flake8==1.0.6->-r requirements.txt (line 4)) (4.0.1)
Requirement already satisfied: idna<4,>=2.5 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from requests->-r requirements.txt (line 1)) (3.3)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from requests->-r requirements.txt (line 1)) (2.0.10)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from requests->-r requirements.txt (line 1)) (1.26.8)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from requests->-r requirements.txt (line 1)) (2021.10.8)
Requirement already satisfied: colorama<0.5.0,>=0.4.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from rich->-r requirements.txt (line 2)) (0.4.4)
Requirement already satisfied: typing-extensions<5.0,>=3.7.4 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from rich->-r requirements.txt (line 2)) (4.0.1)
Requirement already satisfied: commonmark<0.10.0,>=0.9.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from rich->-r requirements.txt (line 2)) (0.9.1)
Requirement already satisfied: pygments<3.0.0,>=2.6.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from rich->-r requirements.txt (line 2)) (2.11.2)
Requirement already satisfied: pycodestyle<2.9.0,>=2.8.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from flake8>=3.5->pytest-flake8==1.0.6->-r requirements.txt (line 4)) (2.8.0)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from flake8>=3.5->pytest-flake8==1.0.6->-r requirements.txt (line 4)) (0.6.1)
Requirement already satisfied: importlib-metadata<4.3 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from flake8>=3.5->pytest-flake8==1.0.6->-r requirements.txt (line 4)) (4.2.0)
Requirement already satisfied: pyflakes<2.5.0,>=2.4.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from flake8>=3.5->pytest-flake8==1.0.6->-r requirements.txt (line 4)) (2.4.0)
Requirement already satisfied: isort<6,>=4.2.5 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pylint>=2.3.0->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (5.10.1)
Requirement already satisfied: platformdirs>=2.2.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pylint>=2.3.0->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (2.4.1)
Requirement already satisfied: astroid<2.10,>=2.9.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pylint>=2.3.0->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (2.9.2)
Requirement already satisfied: pluggy<2.0,>=0.12 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest>=5.4->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (1.0.0)
Requirement already satisfied: iniconfig in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest>=5.4->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (1.1.1)
Requirement already satisfied: packaging in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest>=5.4->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (21.3)
Requirement already satisfied: atomicwrites>=1.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest>=5.4->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (1.4.0)
Requirement already satisfied: py>=1.8.2 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest>=5.4->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (1.11.0)
Requirement already satisfied: attrs>=19.2.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from pytest>=5.4->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (21.4.0)
Requirement already satisfied: typed-ast<2.0,>=1.4.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from astroid<2.10,>=2.9.0->pylint>=2.3.0->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (1.5.1)
Requirement already satisfied: setuptools>=20.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from astroid<2.10,>=2.9.0->pylint>=2.3.0->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (41.2.0)
Requirement already satisfied: wrapt<1.14,>=1.11 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from astroid<2.10,>=2.9.0->pylint>=2.3.0->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (1.13.3)
Requirement already satisfied: lazy-object-proxy>=1.4.0 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from astroid<2.10,>=2.9.0->pylint>=2.3.0->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (1.7.1)
Requirement already satisfied: zipp>=0.5 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from importlib-metadata<4.3->flake8>=3.5->pytest-flake8==1.0.6->-r requirements.txt (line 4)) (3.7.0)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in c:\users\redbeanw\appdata\local\programs\python\python37\lib\site-packages (from packaging->pytest>=5.4->pytest-pylint==0.18.0->-r requirements.txt (line 3)) (3.0.6)

But when I follow the README.md it doesn't work.

C:\Users\RedbeanW\Desktop\Repo\huami-token>python3 huami_token.py --method xiaomi --bt_keys

C:\Users\RedbeanW\Desktop\Repo\huami-token>

The program exits immediately without any output. Please help me, thanks.

No 'auth_key'

I have run script with method xiaomi (python huami_token.py --method xiaomi --bt_keys)
After paste the Mi account url (https://hm.xiaomi.com/watch.do?code=ALSG_CLOUDSRV_9DA32AAC0A9D5124CB92157C********)
This is the result. It looks like I have success log int but the script can't get the auth_key?

Paste URL after redirection here.
https://hm.xiaomi.com/watch.do?code=ALSG_CLOUDSRV_9DA32AAC0A9D5124CB92157C********
Token: ['ALSG_CLOUDSRV_9DA32AAC0A9D5124CB92157C********']
Logging in...
Logged in! User id: 3023231688
Getting linked wearables...
Traceback (most recent call last):
  File "huami_token.py", line 356, in <module>
    wearables = device.get_wearables()
  File "huami_token.py", line 190, in get_wearables
    raise ValueError("No 'auth_key' parameter in device data.")
ValueError: No 'auth_key' parameter in device data.

Device: Mi Band 6
Phone: Iphone 10s

amazfit vs. mi fit

Hello
I have a mi band 4 and use the 'MI FIT' app with a huami account.
When I run your script I come to a page that says:
Sign in to Amazfit with Mi Account
When I try to use my huami account it does not recognize me.

Do I need to download the amazfit app and register with this the mi band?

Best regards

Google login method

If im not mistaken this won't work with Google accounts? I have made/logged in with Google account in Mi Fit -app and now that i ran the python script the login page doesn't have option to login with google so reqular Mi Account is required to run this?

Also sorry if this is noobish info, but I ran this in linux and that for I had to specify python version to run this. Reqular python huami_token.py gave syntax error, but running python3.7 it worked perfectly.

Login fails with code 0106

Somehow this does not work for me:

> python3 huami_token.py --method xiaomi --bt_keys
Getting access token with xiaomi login method...
Copy this URL to web-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

and login to your Mi account.

Paste URL after redirection here.
https://hm.xiaomi.com/watch.do?code=ALSG_CLOUDSRV_....
Token: ['ALSG_CLOUDSRV_....']
Logging in...
Traceback (most recent call last):
  File "huami_token.py", line 248, in <module>
    device.login()
  File "huami_token.py", line 107, in login
    raise ValueError(f"Login error. Error: {login_result['error_code']}")
ValueError: Login error. Error: 0106

Amazfit account : SyntaxError: invalid syntax

Hi,

the script could not be executed successfully.
I am double checked the dependencies in the readme.md, but I could not found any errors.

File "huami_token.py", line 42
    print(f"Getting access token with {self.method} login method...")
                                                                   ^
SyntaxError: invalid syntax

Model: Amazfit Bip S
System: openSuse Tumbleweed.

Any ideas?

Thanks!
Thomas

Regarding acquiring auth key for Mi Band 4/5

Apps like Notify and Fitness, Master for Mi Band doesn't need user credentials to acquire auth key when Mi Fit app is installed.

They somehow acquire the auth key from Mi Fit app. I couldn't find how they do it.

Please help me regarding this matter and I am even willing to pay for your help.

Thanks

Rich is a dependency

Traceback (most recent call last):
File "huami_token.py", line 11, in
from rich.console import Console

Error occurs until you run pip3 install rich to get rich! Might pay to update the README.md with this.

Login error

Hi, I'm having this same problem, but the solution didn't worked for me. I downloaded Zepp app and could not login using mu xiaomi account credentials. So, I created a Zepp account using the same email and password but the problem persists

py huami_token.py --method xiaomi --email [email protected] --password xxxxxxx--bt_keys
Getting access token with xiaomi login method...
Copy this URL to web-browser

https://account.xiaomi.com/oauth2/authorize?skip_confirm=false&client_id=xxxxxxxx

and login to your Mi account.

Paste URL after redirection here.
https://hm.xiaomi.com/watch.do?code=ALSG_CLOUDSRV_xxxxxxxxxx
Token: ['ALSG_CLOUDSRV_xxxxxxxxx']
Logging in...
Traceback (most recent call last):
  File "C:\Users\xxxxx\huami-token\huami_token.py", line 265, in <module>
    device.login()
  File "C:\Users\xxxxxx\huami-token\huami_token.py", line 116, in login
    raise ValueError(f"Login error. Error: {login_result['error_code']}")
ValueError: Login error. Error: 0117


Unauthorized error for AGPS download

Version: 6efae23

$ python huami_token.py -m xiaomi -g
Getting access token with xiaomi login method...
Copy this URL to web-browser

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

and login to your Mi account.

Paste URL after redirection here.
https://hm.xiaomi.com/watch.do?code=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Token: ['XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX']
Logging in...
Logged in! User id: xxxxxxxxxx
Downloading AGPS_ALM...
Traceback (most recent call last):
  File "/Users/lacek/huami-token/huami_token.py", line 360, in <module>
    device.get_gps_data()
  File "/Users/lacek/huami-token/huami_token.py", line 237, in get_gps_data
    response.raise_for_status()
  File "/Users/lacek/miniconda3/envs/huami-token/lib/python3.9/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api-mifit-us2.huami.com/apps/com.huami.midong/fileTypes/AGPS_ALM/files

Invalid syntax

I've processed all the prerequisite steps, when I run the script [either amazefish or xiaomi login method] I get the following error:

File "huami_token.py", line 65 def get_access_token(self) -> str: ^ SyntaxError: invalid syntax

Syntax Error: def get_access_token(self) -> str:

I have cloned the repo and installed python on my MAC OS version 10.15.5

When I try to run the command it keep showing me this error message in terminal

MacBook-Pro:huami-token patrik$ python huami_token.py --method xiaomi --bt_keys
  File "huami_token.py", line 46
    def get_access_token(self) -> str:
                               ^
SyntaxError: invalid syntax

Error 401 when correct details are inputted (Amazfit Method)

Getting access token with amazfit login method...
Traceback (most recent call last):
File "C:\Users\linux\huami-token\huami_token.py", line 352, in
device.get_access_token()
File "C:\Users\linux\huami-token\huami_token.py", line 101, in get_access_token
raise ValueError(f"Wrong E-mail or Password."
ValueError: Wrong E-mail or Password.Error: ['401']

ModuleNotFound

Traceback (most recent call last):
File "huami_token.py", line 35, in
import requests
ModuleNotFoundError: No module named 'requests'

This error pops up whenever I type in my credentials into powershell for getting the key.

invalid syntax (self.method)

Hi all,
get the error:

~$ python huami_token.py --method xiaomi --bt_keys
python: can't open file 'huami_token.py': [Errno 2] No such file or directory

Some Idea?

Greetings

Unable to use program to login

Utilising the following layout I am receiving this error
./huami_token.py -m amazfit -e [email protected] -p ***** -b

Getting access token with amazfit login method...
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/models.py", line 380, in prepare_url
scheme, auth, host, port, path, query, fragment = parse_url(url)
File "/usr/lib/python3/dist-packages/urllib3/util/url.py", line 392, in parse_url
return six.raise_from(LocationParseError(source_url), None)
File "", line 2, in raise_from
urllib3.exceptions.LocationParseError: Failed to parse: https://api-user.huami.com/registrations/me%40gmail.com/tokens

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./huami_token.py", line 247, in
device.get_access_token()
File "./huami_token.py", line 66, in get_access_token
response = requests.post(auth_url, data=data, allow_redirects=False)
File "/usr/lib/python3/dist-packages/requests/api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 516, in request
prep = self.prepare_request(req)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 449, in prepare_request
p.prepare(
File "/usr/lib/python3/dist-packages/requests/models.py", line 314, in prepare
self.prepare_url(url, params)
File "/usr/lib/python3/dist-packages/requests/models.py", line 382, in prepare_url
raise InvalidURL(*e.args)
requests.exceptions.InvalidURL: Failed to parse: https://api-user.huami.com/registrations/me%40gmail.com/tokens

Maybe the urls have change lately

Error in line 65

I keep getting this error:

File "huami_token.py", line 65
def get_access_token(self) -> str:
^
SyntaxError: invalid syntax

Would hugely appreciate any help with hot to make it work?

Support downloading watchfaces

Some time ago i wrote something similar to your program to download watchface :

To download list of wf for chaohu(bip):
"/discovery/cards/chaohu_watch_skins"
To download list of wf for tempo(cor):
"/discovery/cards/tempo_watch_skins"

headers = {
<-->SafeString("accept"): "application/x.Huami.v1+json; districts={{}};",
<-->SafeString("authorization"):     "Bearer ****************
<-->SafeString("accept-language"):   "en",
<-->SafeString("user-agent"):        "Mozilla/5.0 (Linux; Android 9; GT-I9505 Build/PQ3A.190801.002;
<-->SafeString("range"):             "max=10000",
<-->SafeString("sec-fetch-mode"):    "cors",
<-->SafeString("origin"):            "https://fe-cdn.huami.com",
<-->SafeString("x-requested-with"):  "com.huami.watch.hmwatchmanager",
<-->SafeString("sec-fetch-site"):    "same-site",
<-->SafeString("referer"):           "https://fe-cdn.huami.com/watch-skins/2.0.8/index.html",
<-->SafeString("accept-encoding"):   "identity",
}
params = {
#SafeString("category"):     "tempo_watch_skins",
<-->SafeString("category"):     "chaohu_watch_skins",
<-->SafeString("user_country"): "us",
<-->SafeString("pageSize"):     "20",
<-->SafeString("districts"): "",
    "v": "%d" % (time.time() * 1000),
}

for more recent watches the api was:
/market/watch/apps/1

with these headers/params

language ="en_US"
>h = {
><-->SafeString("channel"): "Normal",
><-->SafeString("country"): country,
><-->SafeString("cv"): self.cv,
><-->SafeString("lang"): language,
><-->
>}
>p = {
     "Channel": "Normal",
     SafeString("country"): country,
     SafeString("cv"): self.cv,
     SafeString("lang"): language,
     "user_region":  "4",
     "customizable": "disable",
      "per_page":     "36",
     "per_page":     "200",
     "page":         "1",
     "device":       deviceid
}

Feel free to add into you tool
Regards

404 Error after logged by XIaomi Account

I bond the Miband 6 with Mi Fit. But after I clicked the link and logging, the return code was 404 and it said that routes not found. Could you help me? I've reset the band and reconnected it with Mi Fit several times, but it didn't work.

no mac or auth_key analyzed

https://hm.xiaomi.com/watch.do?code=C3_003023863265D3316E355FFA16B4867B
Token: ['C3_003023863265D3316E355FFA16B4867B']
Logging in...
Logged in! User id: 1112235618
Getting linked wearables...
+------------------------------------------------------------------------------+
| ID | ACT | MAC | auth_key |
|-----+-----+-------------------+----------------------------------------------|
+------------------------------------------------------------------------------+

Logged out.

Xiaomi doesn't return any linked wearables

When using the script to get the token with $ python huami_token.py -m xiaomi -e [email protected] -p password123 --bt_keys, I receive an empty list of linked wearables.

Paste URL after redirection here.
https://hm.xiaomi.com/watch.do?code=ALSG_CLOUDSRV_123BBAEDABDOE
Token: ['ALSG_CLOUDSRV_123BBAEDABDOE']
Logging in...
Logged in! User id: 123456789
Getting linked wearables...
+-------------------------------------------------------------------------------+
| ID  | ACT |        MAC        |                   auth_key                    |
|-----+-----+-------------------+-----------------------------------------------|
+-------------------------------------------------------------------------------+

Obviously I have linked the Mi Band 6 to the Mi Fit app and followed the steps in #32 to get it to work in the first place.

Login Error 0106 - Mi

Hi, I am getting the following error after pasting the url

Logging in...
Traceback (most recent call last):
  File "huami_token.py", line 252, in <module>
    device.login()
  File "huami_token.py", line 108, in login
    raise ValueError(f"Login error. Error: {login_result['error_code']}")
ValueError: Login error. Error: 0106

ValueError: Login error. Error: 0125

I'm trying to get the auth_key for Mi Band 6 but after pasting the url I get the following error

Snipaste_2022-06-26_13-07-58

These are my request details:

{
  "dn": "account.huami.com,api-user.huami.com,app-analytics.huami.com,api-watch.huami.com,api-analytics.huami.com,api-mifit.huami.com",
  "app_version": "5.9.2-play_100355",
  "source": "com.huami.watch.hmwatchmanager",
  "country_code": "US",
  "device_id": "02:00:00:01:41:31",
  "third_name": "mi-watch",
  "lang": "en",
  "device_model": "android_phone",
  "allow_registration": "false",
  "app_name": "com.huami.midong",
  "code": [
    "my code here"
  ],
  "grant_type": "request_token"
}

amazfit No 'country_code' parameter in login url.

Hello,

I tried to get the key but i get this message:

Traceback (most recent call last):
File "huami_token.py", line 264, in
device.get_access_token()
File "huami_token.py", line 88, in get_access_token
raise ValueError("No 'country_code' parameter in login url.")
ValueError: No 'country_code' parameter in login url.

I use python 3.8 on ubuntu 20.04

please,help me fix it!!!!

huami-token-master> python huami_token.py --method xiaomi --bt_keys

Getting linked wearables...
Traceback (most recent call last):
File "F:\小米手环\huami-token-master\huami-token-master\huami_token.py", line 356, in
wearables = device.get_wearables()
File "F:\小米手环\huami-token-master\huami-token-master\huami_token.py", line 190, in get_wearables
raise ValueError("No 'auth_key' parameter in device data.")
ValueError: No 'auth_key' parameter in device data.

Amazfit account : Client Error: Unauthorized for url: https://account.huami.com/v2/client/login

Hi and thanks for this nice initiative.

I wanted to get the BT keys as well as AGPS files from a Stratos 3, but using huami-token from MacOS gives me this error:

➜ ./huami_token.py -m amazfit -e "[email protected]" -p "redacted" --bt_keys
Getting access token with amazfit login method...
Token: ['redacted']
Logging in...
Traceback (most recent call last):
  File "./huami_token.py", line 252, in <module>
    device.login()
  File "./huami_token.py", line 104, in login
    response.raise_for_status()
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://account.huami.com/v2/client/login

I confirmed that the email address and password are correct - that's the ones i used when connecting using the Amazfit / Zepp app on Android.

Any idea?

Thanks!
Nico

method amazfit - ValueError: Wrong E-mail or Password.Error: ['401']

I created a Zepp account using the same email and password for my AMAZFIT GTR.
Zepp APP works.
method xiaomi works - but no auth_key

To login with your Zepp credentials, use --method amazfit parameter, get error:
ValueError: Wrong E-mail or Password.Error: ['401']

python3 huami_token.py --method amazfit --email ******* --password ******** --bt_keys

Result:

AUTH: https://api-user.huami.com/registrations/*******/tokens {
     'state': 'REDIRECTION', 
	 'client_id': 'HuaMi', 
	 'password': '********', 
	 'redirect_uri': 'https://s3-us-west-2.amazonws.com/hm-registration/successsignin.html', 
	 'region': 'us-west-2', 
	 'token': 'access', 
	 'country_code': 'US'
	 }

REDIRECT: ParseResult(scheme='https', 
                      netloc='s3-us-west-2.amazonws.com', 
		      path='/hm-registration/successsignin.html', 
					  params='', 
					  query='error=401&state=REDIRECTION&region=eu-central-1', fragment='') {
					     'error': ['401'], 
						 'state': ['REDIRECTION'], 
						 'region': ['eu-central-1']
					  }

Traceback (most recent call last):
  File "/Users/******/huami-token/huami_token.py", line 356, in <module>
    device.get_access_token()
  File "/Users/*****/huami_token.py", line 105, in get_access_token
    raise ValueError(f"Wrong E-mail or Password." \
ValueError: Wrong E-mail or Password.Error: ['401']

It looks like that the REDIRECT is the problem.

How can i fix this ?
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.