kiwiz / gkeepapi

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

API token refresh bloats google account with sessions? #129

Closed flecmart closed 2 years ago

flecmart commented 2 years ago

Hi there,

first - thank you for your great library :-)

I use it to move list items from google keep to todoist periodically. This script runs always in the background and it only calls keep.login() once at the start. From the documentation I know that gkeepapi "takes care of refreshing API tokens, so there’s no need to call Keep.login() again".

Shortly after I started my script I noticed that I get logged out of my google account every other day e.g. on my android device. I researched a bit and I saw the following in my security tab in my google account:

image

I have the feeling that all those sessions will cause google to log me out of my account in the first place and I can clearly connect those sessions to my script using gkeepapi.

Do you have an idea on how to solve this problem? I thought about using the master token, but actually I just login once at the start of the script (and then it runs "forever"). I use an app password as recommended and I wonder why gkeepapi keeps spawning new sessions.

Thanks again, Martin

flecmart commented 2 years ago

hmm I guess it is related to gpsoauth: https://github.com/simon-weber/gpsoauth/issues/2

I did not set a device_id. I try to do this know and see if it resolves my issue.

flecmart commented 2 years ago

So I managed to fix this behavior by providing a device_id. It cannot be any device_id though, but it has to be a 16 digit hexadecimal like documented here: https://unofficial-google-music-api.readthedocs.io/en/develop/reference/mobileclient.html#gmusicapi.clients.Mobileclient.oauth_login

kiwiz commented 2 years ago

Glad you got it working. By default, gkeepapi defaults to your MAC address which is typically stable. Any chance you're using MAC address randomization?

flecmart commented 2 years ago

Hmm interesting,

I run the code inside a docker container... Not entirely sure how the networking stuff down to a mac address is handled in there.

But could be randomized on container restart and I also had a bug in my code which resulted in the container restarting periodically.

I think this can be closed then ☺️