kiwiz / gkeepapi

An unofficial client for the Google Keep API.
MIT License
1.53k stars 114 forks source link

Loggin issue with AppPassword #144

Closed rhalaly closed 9 months ago

rhalaly commented 1 year ago

I'm using Windows 11 and Python 3.7. I have Google account with 2-Step authentication, so I generated AppPassword. But when I use it I still get

gkeepapi.LoginException: ('NeedsBrowser', 'To access your account, you must sign in on the web. Touch Next to start browser sign-in.')

What can I do further? I already created an AppPassword named gkeepapi but it still not working...

jkitching commented 1 year ago

I encountered this error running an old version of gpsoauth. Looks like the fix was published in gpsoauth==1.0.1:

https://github.com/simon-weber/gpsoauth/issues/37

Cris70 commented 1 year ago

@jkitching if I use your docker image (see here) I get the same error (NeedsBrowser).

If I use your glogin.py script in my virtualenv I get {"Error": "BadAuthentication"}.

My virtualenv has these components:

jalukii commented 11 months ago

I am facing the same problem, but it is more strange. Yesterday, when I started implementing my thing with gkeepapi, I got gkeepapi.exception.BrowserLoginRequiredException: https://accounts.google.com/signin/continue?sarp=1&scc=1&continue=https://accounts.google.com/o/android/auth?hl%3Den_us%26xoauth_display_name%3DAndroid%2BLogin%2BService%26source%3DAndroid%2BLogin&plt=...

Strangely enough, it suddenly started working, so I finished my thing. Today I woke up, ran my script and it broke again. Same error, but the same configuration. Are there some Google changes? Or where can be the problem? I figured out, the auth post failed DEBUG:urllib3.connectionpool:https://android.clients.google.com:443 "POST /auth HTTP/1.1" 403 None but I don't change any credentials. I tried to generate a new AppPassword, but won't work.

vojtechmarek-dev commented 10 months ago

Hi I am having same problem with trying to login to Gkeep via app password i get gkeepapi.exception.BrowserLoginRequiredException

is there a solution for this?

robin-pham commented 10 months ago

Same, ran into this "gkeepapi.exception.BrowserLoginRequiredException" issue yesterday as well (am currently using an AppPassword with 2FA). Wondering if Google changed something

derekantrican commented 10 months ago

Just started seeing this after the new keep update (#153). My code was working fine until I pulled the latest version of the gkeepapi library, then I started seeing this issue. I'm also using an app password on a 2FA account like a few others here.

I put the link (like @jalukii shared) into my browser, went through a couple auth prompts, then hit an endless "please wait a moment" screen. So not as simple as following the link.

flecmart commented 10 months ago

Hey,

I am also currently trying to resolve this for my own project and I just leave my findings and thoughts here - maybe they help someone.

The only combination of requirements that still works for me is:

urllib3<2
gpsoauth==1.0.2
gkeepapi==0.14.2

Additionaly you need to have openssl version 1 on OS level. I achieve this for example by using python:3.11-bullseye image for docker.

As soon as you upgrade your openssl version you will get Bad Authentication exception and as soon as I upgrade gpsoauth to a more recent version I get exactly the same behavior that you are describing in this issue.

@kiwiz What environment are you developing/testing on? I would like to bump gkeepapi and gpsoauth but I cannot get it to work and I am out of ideas at this moment.

rchampion commented 10 months ago

I can't seem to get any combination of python versions or requirements to login. Hoping a solution is presented soon!

robin-pham commented 10 months ago

I gave up completely on using Google Keep, as this authentication method seems to break every other year or so. If anyone was using this library for personal reasons I recommend something with actual official/OAuth support like Google Tasks (though who knows how long Google will keep this around either 😂).

derekantrican commented 10 months ago

I would love to move to something else, but I use this library because Google Assistant has moved to exclusively using Keep for notes & lists (I use the "Note to Self" command a lot). They used to provide the option to set your own notes app, but they took that away. So now I use this library to mirror my notes to my email.

robin-pham commented 10 months ago

Yeah that's exactly why I was using this library as well, for Google Assistant mirroring! I found out that if you use the "Add task" command, it adds to Google Tasks, so I no longer have to use note to self or add to my todo list/shopping list and no longer have to deal with Google Keep.

rchampion commented 10 months ago

I would love to move to something else, but I use this library because Google Assistant has moved to exclusively using Keep for notes & lists (I use the "Note to Self" command a lot). They used to provide the option to set your own notes app, but they took that away. So now I use this library to mirror my notes to my email.

Same. I have a script that takes Keep Notes and puts them in a bullet point list in Notion for me. Then I have GA devices all over my house, my watch, and my phone so I can voice note from anywhere. This API is literally the only way to accomplish this core part of my day to day.

robin-pham commented 10 months ago

Funny that we've all been using this library for a similar purpose, i.e. Google Assistant devices -> Make a Keep note with voice -> Sync to some other service.

Just FYI, I succesfully migrated my flow to Google Tasks, since it has an API officially supported by Google and has an easy OAuth method to manage personal auth, and their underlying model/API is very similar to Keep. Basically the same voice command except instead of "note to self"/"add to todo", it's "Add Task ___".

viertel97 commented 10 months ago

Just FYI, I succesfully migrated my flow to Google Tasks, since it has an API officially supported by Google and has an easy OAuth method to manage personal auth, and their underlying model/API is very similar to Keep. Basically the same voice command except instead of "note to self"/"add to todo", it's "Add Task ___".

Could you elaborate that a little bit? (Not sure if this is the right place for it) Does it also have the same functionality regarding different lists? Eg. Add Task to List "Shopping List" or "ToDo-List"? And do you have a source regarding using the API via Python?

robin-pham commented 10 months ago

Could you elaborate that a little bit?

Python quickstart guide + code.

^ has the instructions on how to get an app running. You do need a Google Cloud project, but the API itself costs nothing so I haven't been getting charged. Basically I have a background worker script that polls Tasks, once it sees a new one, mirrors the tasks in my other service, then deletes the Task so I don't get reminders.

Does it also have the same functionality regarding different lists? Eg. Add Task to List "Shopping List" or "ToDo-List"?

The Tasks app itself has different lists, but the voice commands don't work with being able to add to a specific list, it'll always add tasks to the default list sadly.

derekantrican commented 10 months ago

For me, the "Add a task" flow always gives a second prompt of "When do you want to be reminded?". So it's not really a drop-in replacement

derekantrican commented 10 months ago

I just my original code working and wanted to share the solution. This is similar to @flecmart 's post above and I got it from a consumer of this project: https://github.com/djsudduth/keep-it-markdown/issues/72

I ran the following:

After this, my original code worked with the latest version of gkeepapi

viertel97 commented 10 months ago

I just my original code working and wanted to share the solution. This is similar to @flecmart 's post above and I got it from a consumer of this project: djsudduth/keep-it-markdown#72

I ran the following:

  • pip install urllib3==1.25.1
  • pip install gpsoauth==1.0.2

After this, my original code worked with the latest version of gkeepapi

I can confirm this! I used that https://github.com/djsudduth/keep-it-markdown/issues/72#issuecomment-1793495242 code to gather the master token and then could login with keep.resume(GOOGLE_MAIL, TOKEN) and the following dependencies:

gpsoauth==1.0.4
gkeepapi==0.15.1
csimpf commented 10 months ago

Hey @derekantrican @viertel97 I attempted those steps but was still getting the same BrowserLoginRequiredException I was getting with gkeepapi and wasn't able to get further. Do you have any pointers for this?

(Either way - I was able to keep using my existing version of gkeepapi; v0.14.2 by deleting tags from my notes as per https://github.com/kiwiz/gkeepapi/issues/155#issuecomment-1870691191)

Cris70 commented 10 months ago

I just my original code working and wanted to share the solution. This is similar to @flecmart 's post above and I got it from a consumer of this project: djsudduth/keep-it-markdown#72 I ran the following:

  • pip install urllib3==1.25.1
  • pip install gpsoauth==1.0.2

After this, my original code worked with the latest version of gkeepapi

I can confirm this! I used that djsudduth/keep-it-markdown#72 (comment) code to gather the master token and then could login with keep.resume(GOOGLE_MAIL, TOKEN) and the following dependencies:

gpsoauth==1.0.4
gkeepapi==0.15.1

Worked for me too!!! Thank you!

kiwiz commented 9 months ago

Closing in favor of #81