Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

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

Closed
Didier-Croes opened this issue Feb 19, 2021 · 8 comments
Closed

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

Didier-Croes opened this issue Feb 19, 2021 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@Didier-Croes
Copy link

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
Copy link
Owner

Hello. How do you run the script?

@argrento argrento self-assigned this Feb 19, 2021
@argrento argrento added the bug Something isn't working label Feb 19, 2021
@Didier-Croes
Copy link
Author

Didier-Croes commented Feb 19, 2021 via email

@argrento
Copy link
Owner

argrento commented Feb 19, 2021

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

if 'country_code' not in redirect_url_parameters:
.

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
Copy link
Author

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

@Didier-Croes
Copy link
Author

I have an amazfit bip S

@argrento
Copy link
Owner

As a temporary workaround:

  1. Comment line 87:
    if 'country_code' not in redirect_url_parameters:
  2. Comment line 88
    raise ValueError("No 'country_code' parameter in login url.")
  3. Update line 91:
    self.country_code = redirect_url_parameters['country_code']
    to self.country_code = "EU"

This should fix the problem.

@Didier-Croes
Copy link
Author

That solved the issue
thanks a lot

@argrento
Copy link
Owner

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants