Skip to main content

extends the capabilities of the earthengine-api by providing custom session management and client interactions

Project description

Tests PyPI version Python versions Conda-Forge version License

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 — a service-account key, an EARTHENGINE_TOKEN environment variable, earthengine authenticate OAuth credentials, or Application Default Credentials. 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.

  • 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

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): EARTHENGINE_TOKEN / EE OAuth file
session = EESession.from_default()

Credentials are never resolved implicitly — a bare EESession() constructor call is not supported; always use a from_* factory to build a session. To resolve from the environment explicitly, call EESession.from_default(), which walks local sources only, in this order:

  1. EARTHENGINE_TOKEN environment variable

  2. Earth Engine OAuth file (~/.config/earthengine/credentials)

Application Default Credentials are not included — call EESession.from_application_default() to use them.

To see which source a session ended up using, inspect session.auth_mode (the credential kind: file/oauth/service_account/adc) and session.auth_source (the precise origin: 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

  1. Fork the repository.

  2. Create a new branch:

    git checkout -b feature-branch
  3. Commit your changes:

    git commit -am 'Add new feature'
  4. Push the branch:

    git push origin feature-branch
  5. Create a new Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ee_client-3.0.0.tar.gz (38.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ee_client-3.0.0-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file ee_client-3.0.0.tar.gz.

File metadata

  • Download URL: ee_client-3.0.0.tar.gz
  • Upload date:
  • Size: 38.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ee_client-3.0.0.tar.gz
Algorithm Hash digest
SHA256 de5acebd07d7da2cb6798e5cef33b391fcd9456d417f09568e1f5da1ac8542cc
MD5 deb118ac07ed3be17b85b4dcfa280ef7
BLAKE2b-256 d322f013aa65a31a92c162ec7de115008bebde78486c6cf394a2ca3a969630c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ee_client-3.0.0.tar.gz:

Publisher: release.yaml on dfguerrerom/ee-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ee_client-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: ee_client-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ee_client-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e165e4324f348e247eed68a13d608ce92995b59d6b48840b3ab721a2ac2d2285
MD5 a2e364a0b60cba3f23d9d28076dd6f4d
BLAKE2b-256 c2f34d7f0d6a9db238523893e8d3be2aa003f465b3c40c5dd2203cbe2f6ab13b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ee_client-3.0.0-py3-none-any.whl:

Publisher: release.yaml on dfguerrerom/ee-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page