argrento / huami-token

Script to obtain watch or band bluetooth token from Huami servers
MIT License
412 stars 94 forks source link

amazfit No 'country_code' parameter in login url. #27

Closed Didier-Croes closed 3 years ago

Didier-Croes commented 3 years ago

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

argrento commented 3 years ago

Hello. How do you run the script?

Didier-Croes commented 3 years ago

Hi Thanks for the quick answer

python3 huami_token.py -m amazfit -e pro@croes.eu -p ** -a

Didier

Le ven. 19 févr. 2021 à 10:39, Kirill Snezhko notifications@github.com a écrit :

Hello. How do you run the script?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/argrento/huami-token/issues/27#issuecomment-781958678, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASOAB7PLO24VRFFUNP7VFKLS7YWVBANCNFSM4X4BA36A .

-- Didier Croes, Ph.D Bioinformatician Bruxelles/Brussels Belgique/Belgium

argrento commented 3 years ago

That's weird: just checked and can not reproduce this error. Add this line print(redirect_url_parameters) just before if 'country_code' not in redirect_url_parameters: at the line 87 https://github.com/argrento/huami-token/blob/c1206af390bfde7f0e0d484b3f9e012b0bf2045e/huami_token.py#L87.

And paste the printed line here. It should look like this: {'state': ['REDIRECTION'], 'region': ['us-west-2'], 'access': [TOKEN], 'country_code': ['US'], 'countryState': ['US-NY'], 'expiration': [SOME DIGITS]}

Didier-Croes commented 3 years ago

{'state': ['REDIRECTION'], 'region': ['eu-central-1'], 'access': ['DYpQhfLqAwJQPWV63B6Nt'], 'expiration': ['1614595873']}

Didier-Croes commented 3 years ago

I have an amazfit bip S

argrento commented 3 years ago

As a temporary workaround:

  1. Comment line 87: https://github.com/argrento/huami-token/blob/c1206af390bfde7f0e0d484b3f9e012b0bf2045e/huami_token.py#L87
  2. Comment line 88 https://github.com/argrento/huami-token/blob/c1206af390bfde7f0e0d484b3f9e012b0bf2045e/huami_token.py#L88
  3. Update line 91: https://github.com/argrento/huami-token/blob/c1206af390bfde7f0e0d484b3f9e012b0bf2045e/huami_token.py#L91 to self.country_code = "EU"

This should fix the problem.

Didier-Croes commented 3 years ago

That solved the issue thanks a lot

argrento commented 3 years ago

Great. Thanks for pointing out that sometimes server does not return country_code.