Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aazuspan/eeauth
An account manager for the Earth Engine Python API
https://github.com/aazuspan/eeauth
authentication cli earth-engine earth-engine-python-api google-earth-engine
Last synced: about 1 month ago
JSON representation
An account manager for the Earth Engine Python API
- Host: GitHub
- URL: https://github.com/aazuspan/eeauth
- Owner: aazuspan
- License: mit
- Created: 2023-11-08T22:36:41.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-18T20:47:23.000Z (about 1 year ago)
- Last Synced: 2024-09-15T03:40:52.030Z (2 months ago)
- Topics: authentication, cli, earth-engine, earth-engine-python-api, google-earth-engine
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eeauth
[![Earth Engine Python](https://img.shields.io/badge/Earth%20Engine%20API-Python-green)](https://developers.google.com/earth-engine/tutorials/community/intro-to-python-api)
[![PyPI version](https://badge.fury.io/py/eeauth.svg)](https://badge.fury.io/py/eeauth)
[![Build status](https://github.com/aazuspan/eeauth/actions/workflows/ci.yaml/badge.svg)](https://github.com/aazuspan/eeauth/actions/workflows/ci.yaml)An account manager for the Earth Engine Python API that lets you easily authenticate and switch between multiple Google accounts.
## Installation
### From PyPI
```bash
pip install eeauth
```### From conda-forge
*Coming soon!*
## Usage
### Authenticate
Import `eeauth`, then authenticate a user by running `eeauth.authenticate("username")` and following the usual authentication instructions[^authenticate], being sure to select the correct Google account[^username]. The credentials for each authenticated user are stored by `eeauth` for later use.
```python
import ee
import eeauth# Authenticate and register credentials for multiple accounts
eeauth.authenticate("personal")
eeauth.authenticate("work")
```### Initialize
With two users authenticated, you can now initialize Earth Engine with a specific user and switch between them at will.
```python
# Get tasks from your "personal" account
eeauth.initialize("personal")
ee.data.getTaskList()# And from your "work" account
eeauth.initialize("work")
ee.data.getTaskList()
```### CLI
The `eeauth` command line interface lets you manage your authenticated users from the terminal.
```bash
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.
```## FAQ
### How does it work?
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.
### Can I still use `ee.Initialize()`?
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.
### Is it safe?
Like Earth Engine, `eeauth` stores your credentials in an unencrypted local file[^registry]. As long as you don't share that file, you should be good to go.
[^authenticate]: `eeauth.authenticate` calls `ee.Authenticate` under the hood and accepts the same arguments. The only difference is that `eeauth.authenticate` stores your credentials with your requested username.
[^registry]: Credentials are stored in `~/.config/eeauth/registry.json`.
[^username]: Usernames do not need to match the name of your Google account.