gkeepapi icon indicating copy to clipboard operation
gkeepapi copied to clipboard

LoginException: Unknown

Open rajdeep-biswas opened this issue 7 months ago • 6 comments

I used the OAuth token obtained from developer console Cookies.

 keep.authenticate(<my_email>, <my_oauth_token>)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/miniconda3/envs/gkeep/lib/python3.12/site-packages/gkeepapi/__init__.py", line 746, in authenticate
    auth.load(email, master_token, device_id)
  File "/opt/miniconda3/envs/gkeep/lib/python3.12/site-packages/gkeepapi/__init__.py", line 81, in load
    self.refresh()
  File "/opt/miniconda3/envs/gkeep/lib/python3.12/site-packages/gkeepapi/__init__.py", line 161, in refresh
    raise exception.LoginException(res.get("Error"))
gkeepapi.exception.LoginException: Unknown

rajdeep-biswas avatar Jul 17 '25 04:07 rajdeep-biswas

I haven't encountered this before. Does it only happen on one account? Have you tried another IP address?

kiwiz avatar Aug 20 '25 02:08 kiwiz

Same for me, oauth token also from cookie from https://accounts.google.com/EmbeddedSetup

$ /home/user/.local/share/pipx/venvs/gkeepapi/bin/python ./script.py 
Traceback (most recent call last):
  File "/mnt/google/test/keep/./script.py", line 6, in <module>
    keep.authenticate('[email protected]', master_token)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/gkeepapi/lib/python3.13/site-packages/gkeepapi/__init__.py", line 746, in authenticate
    auth.load(email, master_token, device_id)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/share/pipx/venvs/gkeepapi/lib/python3.13/site-packages/gkeepapi/__init__.py", line 81, in load
    self.refresh()
    ~~~~~~~~~~~~^^
  File "/home/user/.local/share/pipx/venvs/gkeepapi/lib/python3.13/site-packages/gkeepapi/__init__.py", line 161, in refresh
    raise exception.LoginException(res.get("Error"))
gkeepapi.exception.LoginException: Unknown

manwe-pl avatar Oct 11 '25 14:10 manwe-pl

I figured out a fix that works for me -

  1. Go to https://myaccount.google.com/apppasswords or just google search "google app apssword", and generate an app password (keep it copied somewhere).
  2. Run this command in your terminal docker run --rm -it breph/ha-google-home_get-token (make sure docker is installed and is running). (Source: https://github.com/leikoilja/ha-google-home?tab=readme-ov-file#master-token)
  3. When the terminal prompts you for your email, provide it your usual email, but for the password, provide it the app password you just generated.
  4. Then you should see the following happen -
[\*] Getting master token...
[\*] Master token: aas_et/[...]

[\*] Getting access token...
[\*] Access token: ya29.[...]
  1. Copy over the master token into a secrets file. I have never noted it expiring once being generated, so protect it like you'd protect a password.
  2. Then the following Python snippet should work -
import gkeepapi

keep = gkeepapi.Keep()

keep.authenticate(user_email, master_token)

gnotes = keep.find(query='What worked')

for gnote in gnotes:
    print(gnote.title)

@manwe-pl, hope this helps.

rajdeep-biswas avatar Oct 11 '25 14:10 rajdeep-biswas

Thanks, but I cannot use https://myaccount.google.com/apppasswords, my Google Workspace account has Advanced Protection Programme turned on. This disables app passwords. Maybe this causes gkeepapi to fail 🤔

manwe-pl avatar Oct 11 '25 14:10 manwe-pl

@manwe-pl, is it your office gmail account?

rajdeep-biswas avatar Oct 11 '25 14:10 rajdeep-biswas

Simply a Google Workspace one, doesn't matter private or for work.

manwe-pl avatar Oct 11 '25 14:10 manwe-pl