gkeepapi: gkeepapi.LoginException: NeedsBrowser

Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gkeepapi
>>> import getpass
>>> gkeepapi.Keep()
<gkeepapi.Keep object at 0x000001B86923C438>
>>> keep = _
>>> keep.login("********@********", getpass.getpass())
Password:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\EcmaXp\AppData\Roaming\Python\Python36\site-packages\gkeepapi\__init__.py", line 363, in login
    ret = auth.login(username, password, get_mac())
  File "C:\Users\EcmaXp\AppData\Roaming\Python\Python36\site-packages\gkeepapi\__init__.py", line 67, in login
    raise LoginException(res.get('Error'), res.get('ErrorDetail'))
gkeepapi.LoginException: ('NeedsBrowser', 'To access your account, you must sign in on the web. Touch Next to start browser sign-in.')```

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (6 by maintainers)

Commits related to this issue

Most upvoted comments

You need to allow an application to be added via this URL, it will simulate the recaptcha check:

gkeepapi and the packaged used for the Android Application settings don’t support recaptcha, and that’s how google blocks you initially.

I experienced this issue myself when i was trying to test out gkeepapi. Funny thing is, I had disabled two-step authentication and the issue still occurred. So I thought what would happen if I enable two step authentication for my google account to be able to generate app password for my script. It turns out that it worked that way 😃 Hope this helps someone.

I don’t have 2-factor enabled. This means also there is no option for me to create an app password. I still get the error.

Here they suggest 2 options:

Using a fresh install with Python 3.6 gives me this error:

In [11]: keep.login('myemail@gmail.com', getpass.getpass(), 'android_mac')
Password:
Using android_id: 0123456789abcdef
{'name': 'Privat', 'mainId': 'SAMPLE_LABEL_15579203-66cd-48ee-87e3-65a7ff283206', 'timestamps': {'created': '2015-03-03T09:46:30.480Z', 'updated': '2018-05-10T22:02:43.861Z'}}
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-11-b6639a94b661> in <module>()
----> 1 api.login('myemail@gmail.com', getpass.getpass(), '0123456789abcdef')

D:\Hannes\dev\gkeepapi\gkeepapi\__init__.py in login(self, username, password, android_id)
    351         ret = auth.login(username, password, android_id)
    352         if ret:
--> 353             self.load(auth)
    354
    355         return ret

D:\Hannes\dev\gkeepapi\gkeepapi\__init__.py in load(self, auth)
    365         self._keep_api.setAuth(auth)
    366         self._reminders_api.setAuth(auth)
--> 367         self.sync()
    368
    369     def get(self, node_id):

D:\Hannes\dev\gkeepapi\gkeepapi\__init__.py in sync(self)
    568
    569             if 'userInfo' in changes:
--> 570                 self._parseUserInfo(changes['userInfo'])
    571
    572             if 'nodes' in changes:

D:\Hannes\dev\gkeepapi\gkeepapi\__init__.py in _parseUserInfo(self, raw)
    631                     node = _node.Label()
    632                     logger.debug('Created label: %s', label['mainId'])
--> 633                 node.load(label)
    634                 labels[label['mainId']] = node
    635

D:\Hannes\dev\gkeepapi\gkeepapi\node.py in load(self, raw)
   1352         self._name = raw['name']
   1353         self.timestamps.load(raw['timestamps'])
-> 1354         self._revision = raw['revision']
   1355         self._merged = NodeTimestamps.str_to_dt(raw['lastMerged']) if 'lastMerged' in raw else NodeTimestamps.int_to_dt(0)
   1356

KeyError: 'revision'

#24 should address this.


What worked for me

  • Comment line 1354 in node.py (see #24).
  • Let Keep.login accept a third parameter android_id and pass in one of your Android devices.
  • Go to https://accounts.google.com/b/0/DisplayUnlockCaptcha and click continue.
  • Run keep = keep.login('youremail@gmail.com', getpass.getpass(), 'your_android_mac')

can you use an app pass if getpass() isn’t already?

Added a note to the readme for now.

You need to allow an application to be added via this URL, it will simulate the recaptcha check:

gkeepapi and the packaged used for the Android Application settings don’t support recaptcha, and that’s how google blocks you initially.

This was what worked for me. I’m using my own test (Google) account with no 2FA mechanism enabled, in case anyone was wondering.

success. thanks!

if Error value are equal as “NeedBrowser” then fireing customized warning also help.

  1. warning “Warning: you need setup app password if you using OTP.”)
  2. raise the original error?