LoginException: Unknown
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
I haven't encountered this before. Does it only happen on one account? Have you tried another IP address?
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
I figured out a fix that works for me -
- Go to https://myaccount.google.com/apppasswords or just google search "google app apssword", and generate an app password (keep it copied somewhere).
- 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) - 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.
- Then you should see the following happen -
[\*] Getting master token...
[\*] Master token: aas_et/[...]
[\*] Getting access token...
[\*] Access token: ya29.[...]
- 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.
- 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.
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, is it your office gmail account?
Simply a Google Workspace one, doesn't matter private or for work.