gkeepapi: gkeepapi.exception.LoginException: ('BadAuthentication', None)
I tried to run this code , it gives me the error above.
I tried with the Gmail login and password, then with my email login and an “app password” following these step:
- Enable 2-step authentication in your Google settings.
- Create an app password here: https://myaccount.google.com/apppasswords
- Choose for the app
other, I named itgkeepapiand I generated a password. - I user the generated password in the scrip instead of my Google password.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 13
- Comments: 88 (15 by maintainers)
The easiest workaround while this gets solved is use a docker image with right versions, mine could be found here: https://hub.docker.com/r/rcdeoliveira/gkeepapi
I encountered the same issue on Linux - pinning requests with
pip install requests==2.23.0as described in https://github.com/simon-weber/gpsoauth/issues/24 fixed things for metry using python3.7.7
Here is the script I used to get API token (if anyone needs it)
@distbit0 try installing only the latest gpsoauth from github in a fresh python 3.10+ venv (pip install git+https://github.com/simon-weber/gpsoauth.git@8a5212481f80312e06ba6e0a29fbcfca1f210fd1) using the manual instructions (@rukins “Second way” instructions: https://github.com/rukins/gpsoauth-java?tab=readme-ov-file) to get the Keep token in my comment above. Then install gkeepapi and use that token with your code.
For others - here’s the Docker image I created: FROM ubuntu:22.04 RUN apt update RUN apt install -y python-is-python3 python3-pip RUN apt-get install -y git RUN pip install git+https://github.com/simon-weber/gpsoauth.git@8a5212481f80312e06ba6e0a29fbcfca1f210fd1
Get an OAuth ID using @rukins “Second way” instructions: https://github.com/rukins/gpsoauth-java?tab=readme-ov-file - or log into your Google account via https://accounts.google.com/EmbeddedSetup and use the Chrome extension called “Cookie Tab Viewer” to retrieve the
oauth_tokenLog into the Docker image, paste this script, and run:
python -c 'print(__import__("gpsoauth").exchange_token(input("Email: "), input("OAuth Token: "), input("Android ID: ")))'Enter your Google Email ID, the OAuth ID and any value for the Android ID (I used a fake Mac address)
The Keep Token will display at the top of the returned data array
Thank you @rukins and @kiwiz - that worked. I really hope Google doesn’t change it’s auth again (or, finally moves the official Google Keep API for Workspace to public Keep users)
A sample implementation for storing the master token can be found here.
I have a pending PR (https://github.com/simon-weber/gpsoauth/pull/41) that I can update with (https://github.com/kiwiz/gkeepapi/issues/137) in a couple of days.
I was on python 3.6.1 and I also got the
gkeepapi.exception.LoginException: ('BadAuthentication', None) error. I tried using the solution withfrom google_auth_oauthlib.flow import InstalledAppFlowfrom alils but it didn’t work. I was able to make it work by:success = keep.login('...@gmail.com', 'APP password HERE')@djsudduth My best guess is that it’s related to this. If you’re the mood to debug, it might be interesting to record PCAPs of the TLS traffic on Windows vs Linux to see what the differences are.
It might be easiest to just copy over the master token instead of getting authentication to work. Note that the master token has full access to your account - you should take care when storing it.
@julianfere the above might work for you too.
Got the same issue here… running on python 3.9, followed all instructions in the FAQ. Anything new?
EDIT: It doesn’t work on macOS, but it does on linux (on python 3.8.6). Hope this can help.
@wilsonmfg One potential cause for these issues is described here. Updating to a newer version of Python might change your TLS fingerprint enough to get through the check.
Additionally, try checking out the FAQ for other suggestions to maintain access.
I’m using python 3, and it’s a new clean install. I’m not sure how that “fix” applies