Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report invalid credentials #303

Open
hannesweisbach opened this issue Mar 16, 2022 · 0 comments
Open

Report invalid credentials #303

hannesweisbach opened this issue Mar 16, 2022 · 0 comments

Comments

@hannesweisbach
Copy link

  • Zwift Mobile API client version: 0.2.0, from pypi
  • Python version: Python 3.9.9
  • Operating System: macOS 11.6 (Big Sur)

Description

zwift-client crashes with wrong user credentials instead of giving an error message (or raising an exception).

What I Did

I was testing out zwift-client with a simple script:

from zwift import Client

username = 'xxx'
password = 'yyy'
player_id = 'zzz'
client = Client(username, password)

profile = client.get_profile().profile

print(profile)

and I got a weird error:

Traceback (most recent call last):
  File "/private/tmp/test.py", line 9, in <module>
    profile = client.get_profile().profile()
  File "/usr/local/lib/python3.9/site-packages/zwift/profile.py", line 12, in profile
    return self.request.json('/api/profiles/{}'.format(self.player_id))
  File "/usr/local/lib/python3.9/site-packages/zwift/request.py", line 33, in json
    headers = self.get_headers(accept_type='application/json')
  File "/usr/local/lib/python3.9/site-packages/zwift/request.py", line 27, in get_headers
    "Authorization": "Bearer " + self.get_access_token()
  File "/usr/local/lib/python3.9/site-packages/zwift/auth.py", line 75, in get_access_token
    self.update_token_data()
  File "/usr/local/lib/python3.9/site-packages/zwift/auth.py", line 55, in update_token_data
    self.access_token_expiration = now + self.expires_in - 5
TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'

A single print() statement revealed:

{'error': 'invalid_grant', 'error_description': 'Invalid user credentials'}

As it turns out, I just had a typo in my user name. It would be nice if, instead of crashing, zwift-client would print a message or raise an exception if it detected wrong credentials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant