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:

  1. Enable 2-step authentication in your Google settings.
  2. Create an app password here: https://myaccount.google.com/apppasswords
  3. Choose for the app other, I named it gkeepapi and I generated a password.
  4. 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)

Most upvoted comments

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.0 as described in https://github.com/simon-weber/gpsoauth/issues/24 fixed things for me

try using python3.7.7

I’m getting the same error with both account password without 2fa and app password with 2fa. Please help anyone??

I tried to modify script and get oauth token by “legal” ways of oauth2, but to use that token for API, that particular API must be enabled for your account account, and as Google Keep API is not supported officially, there is no way to enable it for the token.

Here is the error I’m getting while using oauth2

gkeepapi.exception.APIException: {'errors': [{'domain': 'usageLimits', 'reason': 'accessNotConfigured', 'message': 'Access Not Configured. Reminders API has not been used in project 1052062629689 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/reminders.googleapis.com/overview?project=1052062629689 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.', 'extendedHelp': 'https://console.developers.google.com/apis/api/reminders.googleapis.com/overview?project=1052062629689'}], 'code': 403, 'message': 'Access Not Configured. Reminders API has not been used in project 1052062629689 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/reminders.googleapis.com/overview?project=1052062629689 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.'}

Here is the script I used to get API token (if anyone needs it)


import os
from google_auth_oauthlib.flow import InstalledAppFlow

CLIENT_SECRETS_FILE = "secrets.json"
SCOPES = ['https://www.googleapis.com/auth/memento', 'https://www.googleapis.com/auth/reminders']

if __name__ == '__main__':
    os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
    flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)
    credentials = flow.run_console()
    print(flow.credentials.token)


@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_token

Log 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 with from google_auth_oauthlib.flow import InstalledAppFlow from alils but it didn’t work. I was able to make it work by:

  • updating to the latest python (currently 3.9.5): it can be done easily along side your current python version, without interfering with your current setup (see here for how to)
  • activating the 2 step authentification and creating an app password which I use in  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