Skip to main content

Harmonized Python script for DestinE authentication.

Project description

destinepyauth

A Python library for authenticating against DESP (Destination Earth Service Platform) services.

Installation

pip install destinepyauth

Usage

The main entry point is the get_token() function:

from destinepyauth import get_token

# Authenticate (prompts for credentials if not in environment)
result = get_token("highway")

# Access the token
token = result.access_token

Using with requests

from destinepyauth import get_token
import requests

result = get_token("eden")
headers = {"Authorization": f"Bearer {result.access_token}"}
response = requests.get("https://api.example.com/data", headers=headers)

Using with zarr/xarray (netrc support)

For services like CacheB that work with zarr, you can write credentials to ~/.netrc:

from destinepyauth import get_token
import xarray as xr

# Authenticate and write to ~/.netrc
get_token("cacheb", write_netrc=True)

# Now zarr/xarray will use credentials automatically
ds = xr.open_dataset(
    "reference://",
    engine="zarr",
    backend_kwargs={
        "consolidated": False,
        "storage_options": {
            "fo": "https://cacheb.dcms.destine.eu/path/to/data.json",
            "remote_protocol": "https",
            "remote_options": {"client_kwargs": {"trust_env": True}},
        },
    },
)

Available Services

  • cacheb - CacheB data service
  • dea - DEA service
  • eden - Eden broker
  • highway - Highway service (includes token exchange)
  • insula - Insula service
  • streamer - Streaming service

Credential Handling

When you call get_token(), the library will prompt for your credentials with masked input for both username and password - nothing you type will be visible on screen:

from destinepyauth import get_token
result = get_token("highway")
# Username:   (hidden input)
# Password:   (hidden input)

This ensures credentials cannot be accidentally exposed in terminal logs, screen recordings, or shell history.

Two Factor Authentication

If you have 2FA enabled, you will also be prompted to enter an OTP from your authenticator app.

You can enable/disable 2FA in your DestinE platform account settings.

Adding a new service

To integrate a new DestinE service, add an entry to the _REGISTRY dictionary in the ServiceRegistry class:

"your_service": {
    "scope": "openid offline_access",  # OAuth scopes required
    "defaults": {
        "iam_client": "your-client-id",  # From service's IAM registration
        "iam_redirect_uri": "https://your-service.destine.eu/",  # OAuth redirect
    },
    # Optional: only if post-authentication processing is needed
    # "post_auth_hook": your_custom_hook_function,
},

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

destinepyauth-1.0.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

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

destinepyauth-1.0.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file destinepyauth-1.0.0.tar.gz.

File metadata

  • Download URL: destinepyauth-1.0.0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for destinepyauth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 14a83bfddfa44e973e9c060dd9a7058d8b494f9324ab297eb833ed7b1d84f325
MD5 c9ea61949cc9729e0ec8d5d5ef54033b
BLAKE2b-256 3a3375607c962beb89cd09a22a6c3ae16f44b80e42748a3e8140e237c1c79688

See more details on using hashes here.

Provenance

The following attestation bundles were made for destinepyauth-1.0.0.tar.gz:

Publisher: cd.yml on SercoSPA/DestinE-Platform-AuthN

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

File details

Details for the file destinepyauth-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: destinepyauth-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for destinepyauth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79445af52b124e064705a986ec20e9617885735db39834a11ef70a1ad81be37e
MD5 e93d7c68af3945dd247557ab21b4bdb4
BLAKE2b-256 6b7d4168ed2666ea1a4b6de735a992f1a374826f4cab0979ea09c844ef0c3d83

See more details on using hashes here.

Provenance

The following attestation bundles were made for destinepyauth-1.0.0-py3-none-any.whl:

Publisher: cd.yml on SercoSPA/DestinE-Platform-AuthN

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