kiwiz / gkeepapi

An unofficial client for the Google Keep API.
MIT License
1.53k stars 113 forks source link

Keep.sync() marks nodes as synced before they're persisted to the server #162

Open playhere opened 6 months ago

playhere commented 6 months ago

i am using the docker, and i am able to login to google with app password

but after i sync several hundred notes, the 'rate limit exceeded' exception will pop up

i tried to do a exponential resync mechanism, and it turns to impossible because after sync was called, even with exception, next time i run sync, it will run with no exception but the notes are not really synchronized

is it possible to sync the same notes multiple times till the sync succeed?

kiwiz commented 6 months ago

Afaik, this should work. Please post your code.

playhere commented 6 months ago

i am reading my evernotes from sqlite db, and try to sync to google keep, i can only sync a couple hundreds notes each time, and have to wait for 1 day or 2 to sync another hundreds.

code: readfromsqlite.txt

Traceback (most recent call last): File "trysqlite2.py", line 98, in keep.sync() File "/usr/local/lib/python3.8/dist-packages/gkeepapi/init.py", line 1025, in sync self._sync_notes(resync) File "/usr/local/lib/python3.8/dist-packages/gkeepapi/init.py", line 1055, in _sync_notes changes = self._keep_api.changes( File "/usr/local/lib/python3.8/dist-packages/gkeepapi/init.py", line 362, in changes return self.send(url=self._base_url + "changes", method="POST", json=params) File "/usr/local/lib/python3.8/dist-packages/gkeepapi/init.py", line 241, in send raise exception.APIException(error["code"], error) gkeepapi.exception.APIException: {'code': 403, 'message': 'Rate Limit Exceeded', 'errors': [{'message': 'Rate Limit Exceeded', 'domain': 'usageLimits', 'reason': 'rateLimitExceeded'}]}

the rate limit looks like time related, when wait a week, i can sync like 1000 notes, but if only wait one day, only around 200 notes can by synced.

kiwiz commented 6 months ago

Pushed up a tentative fix. Can you try the sync-fix branch?

playhere commented 6 months ago

latest code Requires: Python >=3.10

but my docker installed python 3.8.10 updated code can not run in my environment

unable to test the code

import gkeepapi File "/usr/local/lib/python3.8/dist-packages/gkeepapi/__init__.py", line 24, in <module> class APIAuth: File "/usr/local/lib/python3.8/dist-packages/gkeepapi/__init__.py", line 132, in APIAuth def getAuthToken(self) -> str | None: TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'