keep-it-markdown: FIX to -> Username or password is incorrect (LoginException('BadAuthentication'))

AS OF JAN 2024 THIS METHOD BELOW DOES NOT WORK - THE ONLY METHOD THAT WORKS RIGHT NOW IS IN THE NEW VERSION 0.6.0 (RELEASED 1/28/2024) INSTRUCTIONS. ADDITIONAL INFORMATION IN THE MESSAGE BELOW:

https://github.com/djsudduth/keep-it-markdown/issues/72#issuecomment-1905274630

The easiest fix is to install a fresh version Python 3.9.1, run KIM and then upgrade to >= 3.10.x once the Google token is saved in your keyring.

To do this execute a fresh install of 3.9.1, run pip install urllib3==1.25.1 and pip install gpsoauth==1.0.2, and then run KIM. Once that is done, then upgrade to a higher version of Python.

But, if you’ve already installed 3.10.x or 3.11.x do this:

1) This assumes you already had default system install of Python 3.10.x or 3.11.x 2) For Windows, install pyenv-win and then install Python 3.9.1 using the command pyenv install 3.9.1 (if you have a Mac or Linux - see this page for installation instructions -> https://github.com/pyenv/pyenv ) 3) Set the Python version with pyenv global 3.9.1 4) Run the kim install -> pip install -r requirements.txt 5) Run pip install urllib3==1.25.1 and pip install gpsoauth==1.0.2 (or, pip3 if that is your Python 3 standard) 6) Generate a new Google app password 7) Run python kim.py and login so you can save the Google Keep token to the keyring 8) Uninstall pyenv by deleting the .pyenv directory in your Users/User/folder (see online instructions on how to delete) 9) Run the kim install -> pip install -r requirements.txt for your default Python >3.10.x install from step 1 if you haven’t already

Now kim.py will work in Python 3.10.x and 3.11.x when it loads and gets the Google token from keyring

About this issue

  • Original URL
  • State: open
  • Created 9 months ago
  • Comments: 28 (15 by maintainers)

Most upvoted comments

NOTE: AS OF JAN 2024 THIS NOTE WAS UPDATED TO USE UBUNTU VS DEBIAN TO FIX A NEW ISSUE

Ok @chrisbrasington - here is one fix for you. I was able to setup a Docker container and get the Keep token/key. Then transfer this key to Debian 12. Here is the Dockerfile (just a text file) needed:

FROM ubuntu:22.04 RUN apt update RUN apt install -y python-is-python3 python3-pip RUN apt-get install -y curl RUN apt-get install ca-certificates RUN curl -L -o tmp/keep-it-markdown-0.5.4.tar.gz https://github.com/djsudduth/keep-it-markdown/archive/refs/tags/0.5.4.tar.gz RUN tar -zxvf tmp/keep-it-markdown-0.5.4.tar.gz RUN pip install -r keep-it-markdown-0.5.4/requirements.txt RUN pip install requests==2.23.0 RUN pip install gpsoauth==1.0.2 RUN pip install keyrings.alt

Steps:

  1. Install Docker on any PC (find the online instructions)
  2. Startup Docker (or it will autostart on reboot)
  3. Save the Dockerfile steps above in file on your PC as “Dockerfile”
  4. Go to the command line and run docker build -t kim . in the directory where you saved the Dockerfile (it will take about 5 min to create the image)
  5. Run the image with docker run -it kim
  6. Change the directory to Kim cd keep-it-markdown-0.5.4
  7. Create a temp app password on Google
  8. Run python keep-test.py -t to log in and display the Keep token (keep token will appear be very long - almost 2 lines)
  9. Copy the token by highlighting the entire string and hitting enter
  10. Paste and save the token somewhere safe
  11. Exit the Docker image with exit
  12. Now run KIM in your current OS with the -t switch to save it in the keystore (python kim.py -t <long token here> (you may need a new Google app password to do this)

Let me know if this works! cc @ooker777

NOTE: AS OF JAN 2024 THIS NOTE WAS UPDATED TO USE UBUNTU VS DEBIAN TO FIX A NEW ISSUE

Ok @chrisbrasington - here is one fix for you. I was able to setup a Docker container and get the Keep token/key. Then transfer this key to Debian 12. Here is the Dockerfile (just a text file) needed:

FROM ubuntu:22.04 RUN apt update RUN apt install -y python-is-python3 python3-pip RUN apt-get install -y curl RUN apt-get install ca-certificates RUN curl -L -o tmp/keep-it-markdown-0.5.4.tar.gz https://github.com/djsudduth/keep-it-markdown/archive/refs/tags/0.5.4.tar.gz RUN tar -zxvf tmp/keep-it-markdown-0.5.4.tar.gz RUN pip install -r keep-it-markdown-0.5.4/requirements.txt RUN pip install requests==2.23.0 RUN pip install gpsoauth==1.0.2 RUN pip install keyrings.alt

Steps:

  1. Install Docker on any PC (find the online instructions)
  2. Startup Docker (or it will autostart on reboot)
  3. Save the Dockerfile steps above in file on your PC as “Dockerfile”
  4. Go to the command line and run docker build -t kim . in the directory where you saved the Dockerfile (it will take about 5 min to create the image)
  5. Run the image with docker run -it kim
  6. Change the directory to Kim cd keep-it-markdown-0.5.4
  7. Create a temp app password on Google
  8. Run python keep-test.py -t to log in and display the Keep token (keep token will appear be very long - almost 2 lines)
  9. Copy the token by highlighting the entire string and hitting enter
  10. Paste and save the token somewhere safe
  11. Exit the Docker image with exit
  12. Now run KIM in your current OS with the -t switch to save it in the keystore (python kim.py -t <long token here> (you may need a new Google app password to do this)

Let me know if this works! cc @ooker777

I found this thread incredibly useful, and appreciate all the valuable comments that went into it. To help anyone out in the future who needs to get a gkeep token in an ad-hoc manner, I’ve made this docker image that will let you do it via cli in 1 line.

Just thought I’d leave it here in case it helps anyone else in the future.

@djsudduth thanks for the response. After some deeper poking around, I figured out the issue. The issue wasn’t with the actual login. Unfortunately when the gkeepapi logs in, it also loads the notes. Looks like google has changed something and begun adding a source that says something along the lines of “migrated by google assistant” or something like that. In the backend in gkeepapi it attempts to load the source as a weblink, and assumes that a title and description must exist. Looks like assistant does not include those things, so it throws an exception, which throws all the way out. So from this piece of code it looks like an error logging in, but it’s actually a note parse exception.

I confirmed this by going into google keep and removing those “migrated by google assistant” sources in google keep, and lo and behold, my original implementation began working again. I may see if I can PR the gkeepapi code, but I don’t have a lot of time, and this is a bigger issue with it’s deserialization of the gkeep objects.

@chrisbrasington - no luck on Debian 12 (python 3.8, 3.9, 3.11) - I’m suspecting the updated linux OpenSSL 3.0 is causing the issue. I was able to get Debian 11 to work. If you can find an older image on Windows or Linux you can retrieve the API key once logged in and then save it directly in the keystore on Debian 12 as noted in the README:

“If those steps don’t work, find a Linux or Mac system and run python keep-test.py -t which will display the token with the -t flag. Copy and save this master token in a safe and secure place!!. You can then use that token in KIM with python kim.py -t <token value> which will save it in your keystore.”