kiwiz / gkeepapi

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

login is failing with unknown error #73

Closed nesc1 closed 4 years ago

nesc1 commented 4 years ago

Starting today the login/resume functionality is not working returning the following error:

  File "C:\Users\Nuno\AppData\Roaming\Python\Python38\site-packages\gkeepapi\__init__.py", line 549, in login
    self.load(auth, state, sync)
  File "C:\Users\Nuno\AppData\Roaming\Python\Python38\site-packages\gkeepapi\__init__.py", line 595, in load
    self.sync(True)
  File "C:\Users\Nuno\AppData\Roaming\Python\Python38\site-packages\gkeepapi\__init__.py", line 886, in sync
    self._parseNodes(changes['nodes'])
  File "C:\Users\Nuno\AppData\Roaming\Python\Python38\site-packages\gkeepapi\__init__.py", line 951, in _parseNodes
    self._nodes[curr].indent(node, False)
KeyError: '16f774ba1a2.0c8bbd630c586350'

This was working with no problems until today... now it does not work... any ideas on why this is happening?

Regards, Nuno

kiwiz commented 4 years ago

Can you enable debug logs and send them to me?

https://gkeepapi.readthedocs.io/en/latest/?badge=latest#debug

nesc1 commented 4 years ago

Hi @kiwiz thanks for the reply.

It seems that the parse exception is not being throw:

...
gkeepapi.node.DEBUG = True
...
        print('Authenticating with token')
        try:
            keep.resume(gkeepApiUser, token)
            gkeepApiLoggedIn = True
            print('Success')
        except gkeepapi.exception.LoginException:
            print('Invalid token')
        except gkeepapi.exception.ParseException as e:
            print(e.raw)
        # except Exception as ex:
        #    print("Generic error on authenticate with token: {}".format(ex))
...

and the output is:

Authenticating with token
Traceback (most recent call last):
  File "c:/svn/projs/DoItAll/Compras/resources/gkeepapicomprasupdate.py", line 322, in <module>
    loginIntoGoogleKeep()
  File "c:/svn/projs/DoItAll/Compras/resources/gkeepapicomprasupdate.py", line 110, in loginIntoGoogleKeep
    keep.resume(gkeepApiUser, token)
  File "C:\Users\Nuno\AppData\Roaming\Python\Python38\site-packages\gkeepapi\__init__.py", line 568, in resume
    self.load(auth, state, sync)
  File "C:\Users\Nuno\AppData\Roaming\Python\Python38\site-packages\gkeepapi\__init__.py", line 595, in load
    self.sync(True)
  File "C:\Users\Nuno\AppData\Roaming\Python\Python38\site-packages\gkeepapi\__init__.py", line 886, in sync
    self._parseNodes(changes['nodes'])
  File "C:\Users\Nuno\AppData\Roaming\Python\Python38\site-packages\gkeepapi\__init__.py", line 951, in _parseNodes
    self._nodes[curr].indent(node, False)
KeyError: '16f774ba1a2.0c8bbd630c586350'

Executing with keep.login(gkeepApiUser, gkeepApiPwd) as the same behaviour.

Regards

nesc1 commented 4 years ago

Can anyone login in google keep or is only me that i'me getting this error?

kiwiz commented 4 years ago

Afaik, it's something specific to your account. Can you try adding the following lines to your code and attaching the debug.log that's generated?

import logging

logging.basicConfig(filename='debug.log',level=logging.DEBUG)
nesc1 commented 4 years ago

Hi @kiwiz thank you for the interest.. but looking into the debug log i think this will not help you... it seems, if you want i can send you the user/pwd in a private way for you to test in you side... debug.log

and i do test it with the latest version: Successfully installed gkeepapi-0.11.9

Regards, Nuno

kiwiz commented 4 years ago

@nesc1 Thanks for the log. It actually did help a bit. It seems that your account has an "indented" listitem for which the the parent no longer exists.

Sending me your creds would work, but we can accomplish the same thing with the following steps:

nesc1 commented 4 years ago

Hi @kiwiz thanks for all the attention.

Here are the files generated, i only removed my email and put my@email.com Logs: dump.log debug.log

Regards

pschmitt commented 4 years ago

Same issue here using a Google Apps GSuite account and an app password.

Traceback ```python success = keep.login('me@example.com', 'XXXX') KeyError Traceback (most recent call last) in 2 3 keep = gkeepapi.Keep() ----> 4 success = keep.login('me@example.com', 'XXX') /usr/local/lib/python3.7/site-packages/gkeepapi/__init__.py in login(self, username, password, state, sync) 547 ret = auth.login(username, password, get_mac()) 548 if ret: --> 549 self.load(auth, state, sync) 550 551 return ret /usr/local/lib/python3.7/site-packages/gkeepapi/__init__.py in load(self, auth, state, sync) 593 self.restore(state) 594 if sync: --> 595 self.sync(True) 596 597 def dump(self): /usr/local/lib/python3.7/site-packages/gkeepapi/__init__.py in sync(self, resync) 886 # Hydrate notes and any children. 887 if 'nodes' in changes: --> 888 self._parseNodes(changes['nodes']) 889 890 self._keep_version = changes['toVersion'] /usr/local/lib/python3.7/site-packages/gkeepapi/__init__.py in _parseNodes(self, raw) 951 self._nodes[prev].dedent(node, False) 952 if curr is not None: --> 953 self._nodes[curr].indent(node, False) 954 955 # Attach created nodes to the tree. KeyError: '16c96f98e61.9730947a0f0f3989' ```
pceiley commented 4 years ago

I'm getting the same. G Suite account using an app password.

kiwiz commented 4 years ago

Can you load up the following note and screenshot it? https://keep.google.com/#LIST/1I17QB2o5kyH4KlmdXJxUmZYRK-tDx7dv_sh3Y-EjhVBeKugfL6nG9-21m9_DLO3VXRsi

I'm primarily interested in whether the list item with the text "leite" is in there.

nesc1 commented 4 years ago

Hi @kiwiz , the list is pretty big (automatic fill) and as a lot of entries of "leite" :) as you can see:

image

don't know if this will help you or not: image

you can check the full list here: https://docs.google.com/document/d/1WoPQ09WdXow1QIqU0zwIAHCcGLJEjXP7rm2Zt606AOc/edit?usp=sharing

kiwiz commented 4 years ago

Interesting! It looks like the list item is in the "gel de banho" section, but that actually doesn't show up in the Google Doc. That said, I think I've all the information I need for a fix now.

wizpig64 commented 4 years ago

My personal cron script has been failing since wednesday in a similar way, indenting an item on a node that does not exist. From what I can see with some debugging, I can say it's a list item that was moved from one list to another automatically based on my rules, and I think later i hit X on it in the web ui.

This is on a regular gmail account, not gsuite-related, which makes sense to me.

edit: suppressing KeyError here seems to fix it enough for my automatic todo list to work again.

kiwiz commented 4 years ago

Implemented a fix and pushed up a new version!

If a listitem node points to a parent that doesn't exist, we just mark it as dedented.

nesc1 commented 4 years ago

Thank you @kiwiz, it seems to work ok now

wizpig64 commented 4 years ago

also fixed for me. thank you @kiwiz :)

pceiley commented 4 years ago

Works for me - thanks for the quick fix @kiwiz!