An account manager for the Earth Engine Python API that lets you easily authenticate and switch between multiple Google accounts.
pip install eeauth
Coming soon!
Import eeauth
, then authenticate a user by running eeauth.authenticate("username")
and following the usual authentication instructions1, being sure to select the correct Google account2. The credentials for each authenticated user are stored by eeauth
for later use.
import ee
import eeauth
# Authenticate and register credentials for multiple accounts
eeauth.authenticate("personal")
eeauth.authenticate("work")
With two users authenticated, you can now initialize Earth Engine with a specific user and switch between them at will.
# Get tasks from your "personal" account
eeauth.initialize("personal")
ee.data.getTaskList()
# And from your "work" account
eeauth.initialize("work")
ee.data.getTaskList()
The eeauth
command line interface lets you manage your authenticated users from the terminal.
Usage: eeauth [OPTIONS] COMMAND [ARGS]...
Manage Earth Engine authentication.
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
activate Set USER as the default Earth Engine user.
authenticate Authenticate USER and store their credentials.
list List all authenticated users.
remove Remove USER from the registry.
When you run ee.Authenticate()
, Earth Engine stores a single credential file on your local machine. To initialize with a different account, you typically need to repeat the authentication process, replacing your old credentials with new credentials. eeauth
allows you to store multiple credentials tied to unique usernames, so that you can quickly switch between authenticated users without the hassle of re-authenticating every time.
Earth Engine will continue to store the most recently authenticated credentials, so ee.Initialize()
will work like it always has. You can also run eeauth activate [USER]
in a terminal to change which user gets initialized by default.
Like Earth Engine, eeauth
stores your credentials in an unencrypted local file3. As long as you don't share that file, you should be good to go.
Footnotes
-
eeauth.authenticate
callsee.Authenticate
under the hood and accepts the same arguments. The only difference is thateeauth.authenticate
stores your credentials with your requested username. ↩ -
Usernames do not need to match the name of your Google account. ↩
-
Credentials are stored in
~/.config/eeauth/registry.json
. ↩