extends the capabilities of the earthengine-api by providing custom session management and client interactions
Project description
The Earth Engine Session Client is a Python package that extends the Google Earth Engine (GEE) API by introducing multi-user session management through custom authentication.
Why This Package?
While Google Earth Engine applications can be created using a global service account, this approach has significant limitations: users cannot access their private GEE assets without making them public. This package solves this problem by handling custom authentication, allowing each user to access their own private assets securely.
Unlike the standard GEE API—which relies on a global session object and does not support multi-user environments—this client ensures that each session is authenticated and managed independently with user-specific credentials.
Each session is instantiated via the EESession class, which supports several credential sources — SEPAL headers, a service-account key, an EARTHENGINE_TOKEN, earthengine authenticate OAuth credentials, or Application Default Credentials. SEPAL is one supported source among several. Once authenticated, the session exposes an operations property that provides easy access to key API methods.
Key Features
Custom User Authentication: Enable users to access their private GEE assets without requiring them to be public, solving the limitation of global service account approaches.
SEPAL-based Initialization: Create sessions using SEPAL headers. The required sepal-session-id cookie is automatically used to retrieve GEE credentials.
Multi-User Session Management: Encapsulate user-specific credentials and project data in independent EESession objects.
Enhanced API Operations: Access GEE functionalities via the operations property, which includes methods such as: - get_info: Retrieve detailed information about an Earth Engine object. - get_map_id: Generate a map ID for an Earth Engine image. - get_asset: Fetch information about a specific Earth Engine asset.
Seamless GEE Integration: Integrate custom methods into your existing Earth Engine workflow with minimal changes.
Installation
To install the package, simply use pip:
pip install ee-client
Usage
Initialization and Authentication
The Earth Engine Session Client can be initialized from SEPAL headers (shown here) or from any standard Google/Earth Engine credential source (see Credential sources below). For the SEPAL path, ensure that the headers include the ``sepal-session-id`` cookie, which is used to retrieve the GEE credentials.
from eeclient import EESession
# Example SEPAL headers with the mandatory sepal-session-id cookie.
sepal_headers = {
"cookie": [
"sepal-session-id=your_session_id",
"other_cookie=other_value"
],
"sepal_user": [{
"id": 123,
"username": "your_username",
"googleTokens": {
"accessToken": "your_access_token",
"refreshToken": "your_refresh_token",
"accessTokenExpiryDate": 1234567890,
"REFRESH_IF_EXPIRES_IN_MINUTES": 10,
"projectId": "your_project_id",
"legacyProject": "your_legacy_project"
},
"status": "active",
"roles": ["role1", "role2"],
"systemUser": False,
"admin": False
}]
}
# Create and validate the session with SEPAL headers
session = EESession(sepal_headers)
Credential sources
Beyond SEPAL headers, a session can be built from any standard Google/Earth Engine credential via factory constructors, each holding a live, refreshable credential:
from eeclient import EESession
# Service-account key (dict or path)
session = EESession.from_service_account("sa-key.json")
# EARTHENGINE_TOKEN env var, else ~/.config/earthengine/credentials
session = EESession.from_earthengine_token()
# An existing google.auth Credentials object
session = EESession.from_google_credentials(creds, project="my-project")
# Application Default Credentials (explicit opt-in)
session = EESession.from_application_default()
# Resolve from the environment (opt-in): SEPAL file / EARTHENGINE_TOKEN / EE OAuth file
session = EESession.from_default()
Credentials are never resolved implicitly — a bare EESession() requires a source (pass sepal_headers or use a from_* factory). To resolve from the environment explicitly, call EESession.from_default(), which walks local sources only, in this order:
EARTHENGINE_TOKEN environment variable
Earth Engine OAuth file (~/.config/earthengine/credentials)
Application Default Credentials are not included — call EESession.from_application_default() to use them. Inside a SEPAL environment (a sepal-user home) from_default() is SEPAL-only and fails closed.
To see which source a session ended up using, inspect session.auth_mode (the credential kind: sepal/file/oauth/service_account/adc) and session.auth_source (the precise origin: sepal_session/sepal_file/earthengine_token/ee_oauth_file/service_account/application_default/google_credentials).
Making API Calls
After initializing the session, use the operations property to access the key GEE methods. For example, you can retrieve information about Earth Engine objects, generate map IDs, or fetch asset details:
import ee
# Initialize the Earth Engine library (this can use any authentication method/account)
# The purpose of this is to ensure the ee library is available for use
ee.Initialize()
# Use the operations available in the session
result_info = session.operations.get_info(ee.Number(5))
print(result_info) # the GEE server call is done using the custom EE client
# Example: Generate a map ID for an Earth Engine image
image = ee.Image('COPERNICUS/S2/20190726T104031_20190726T104035_T31TGL')
map_id = session.operations.get_map_id(image)
print(map_id)
# Example: Retrieve asset information
asset_info = session.operations.get_asset("users/your_username/your_asset")
print(asset_info)
Contributing
We welcome contributions from the community. If you wish to help improve this package, please submit issues or pull requests.
Forking and Branching
Fork the repository.
Create a new branch:
git checkout -b feature-branchCommit your changes:
git commit -am 'Add new feature'Push the branch:
git push origin feature-branchCreate a new Pull Request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ee_client-3.0.0rc0.tar.gz.
File metadata
- Download URL: ee_client-3.0.0rc0.tar.gz
- Upload date:
- Size: 38.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
402d1f61c70e090420c9f6e67ab7c94c1816a17890f4872c9a15d7f50bc2a8cb
|
|
| MD5 |
b9eef7daf9ced7a055af9bddf4537869
|
|
| BLAKE2b-256 |
d79a56dd596074b71b06169c1294f56fab1a265c112b546e0d5ce29fd61c3364
|
Provenance
The following attestation bundles were made for ee_client-3.0.0rc0.tar.gz:
Publisher:
release.yaml on dfguerrerom/ee-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ee_client-3.0.0rc0.tar.gz -
Subject digest:
402d1f61c70e090420c9f6e67ab7c94c1816a17890f4872c9a15d7f50bc2a8cb - Sigstore transparency entry: 2128126619
- Sigstore integration time:
-
Permalink:
dfguerrerom/ee-client@9b31df7d840ce670ba5b5cad8b783636d6b155b7 -
Branch / Tag:
refs/tags/v3.0.0rc0 - Owner: https://github.com/dfguerrerom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9b31df7d840ce670ba5b5cad8b783636d6b155b7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ee_client-3.0.0rc0-py3-none-any.whl.
File metadata
- Download URL: ee_client-3.0.0rc0-py3-none-any.whl
- Upload date:
- Size: 35.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e09456d32d3c818e5cc77b916600079d8e19f324a9b95b6043348ddc2392480
|
|
| MD5 |
6a117526b12aefd8e2345137e350b8c5
|
|
| BLAKE2b-256 |
ea19a77fde3e41976358c2128421b49ef1335c432b0dc7fcabc614409b4bd36b
|
Provenance
The following attestation bundles were made for ee_client-3.0.0rc0-py3-none-any.whl:
Publisher:
release.yaml on dfguerrerom/ee-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ee_client-3.0.0rc0-py3-none-any.whl -
Subject digest:
2e09456d32d3c818e5cc77b916600079d8e19f324a9b95b6043348ddc2392480 - Sigstore transparency entry: 2128126874
- Sigstore integration time:
-
Permalink:
dfguerrerom/ee-client@9b31df7d840ce670ba5b5cad8b783636d6b155b7 -
Branch / Tag:
refs/tags/v3.0.0rc0 - Owner: https://github.com/dfguerrerom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9b31df7d840ce670ba5b5cad8b783636d6b155b7 -
Trigger Event:
release
-
Statement type: