lazeroffmichael/ticktick-py

Bad `code` input crashes the library

Opened this issue · 0 comments

C0rn3j commented

I have mindlessly entered the code directly instead of the entire URL, which apparently crashes the library.

There should probably be some input checking.

Cache could not be read at: .token-oauth
Enter the URL you were redirected to: AbRbeF
Traceback (most recent call last):
  File "<path>/main.py", line 345, in <module>
    tickTick()
  File "<path>main.py", line 146, in tickTick
    auth_client = OAuth2(
                  ^^^^^^^
  File "/usr/lib/python3.11/site-packages/ticktick/oauth2.py", line 136, in __init__
    self.get_access_token(check_cache=check_cache, check_env=env_key)
  File "/usr/lib/python3.11/site-packages/ticktick/oauth2.py", line 311, in get_access_token
    token_info = self._request_access_token()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ticktick/oauth2.py", line 212, in _request_access_token
    self._get_redirected_url()
  File "/usr/lib/python3.11/site-packages/ticktick/oauth2.py", line 175, in _get_redirected_url
    self._code, self._state = self._get_auth_response_parameters(url)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/ticktick/oauth2.py", line 200, in _get_auth_response_parameters
    return isolated["code"], isolated["state"]
           ~~~~~~~~^^^^^^^^
KeyError: 'code'