Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

api.sync() silently fails if no token set. #95

Open
ijoseph opened this issue Jan 31, 2021 · 3 comments
Open

api.sync() silently fails if no token set. #95

ijoseph opened this issue Jan 31, 2021 · 3 comments

Comments

@ijoseph
Copy link

ijoseph commented Jan 31, 2021

Expected behavior

 python -c "from todoist import TodoistAPI; api = TodoistAPI(); api.sync()"

outputs a warning indicating no token has been set.

Actual behavior

Fails silently; api.state is empty.

@ijoseph
Copy link
Author

ijoseph commented Jan 31, 2021

I fixed this but don't have perms to open a PR.

diff --git a/setup.py b/setup.py
index b6ec2aa..477d704 100644
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,7 @@ def read(fname):

 setup(
     name="todoist-python",
-    version="8.1.3",
+    version="8.1.4",
     packages=["todoist", "todoist.managers"],
     author="Doist Team",
     author_email="[email protected]",
diff --git a/todoist/api.py b/todoist/api.py
index 089f6dd..bdf42d1 100644
--- a/todoist/api.py
+++ b/todoist/api.py
@@ -347,6 +347,10 @@ class TodoistAPI(object):
         Sends to the server the changes that were made locally, and also
         fetches the latest updated data from the server.
         """
+
+        if not len(self.sync_token) or self.sync_token == '*':
+            print("Warning: token does not appear to be set; is {!r}".format(self.sync_token))
+
         post_data = {
             "token": self.token,
             "sync_token": self.sync_token,

@ijoseph
Copy link
Author

ijoseph commented Jan 31, 2021

Behavior after patch:

❯ python -c "from todoist import TodoistAPI; api = TodoistAPI(); api.sync()"
Warning: token does not appear to be set; is '*' 

@PotHix
Copy link
Member

PotHix commented Feb 1, 2021

I fixed this but don't have perms to open a PR.

You can just fork it and provide a PR. :)

Just be sure to check the token attribute on TodoistAPI instead of sync_token (which is a different thing).

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

No branches or pull requests

2 participants