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.
For example, obtain an access token for the highway service:
from destinepyauth import get_token
# Authenticate (prompts for credentials if not in environment)
result = get_token("highway")
# Access the tokens
access_token = result.access_token
refresh_token = result.refresh_token
Available Services
cacheb- CacheB data servicedea- DEA serviceeden- EDEN brokerhda- Harmonized Data Accesshighway- Highway serviceinsula- Insula servicepolytope- Data access servicestreamer- DestinEStreamer
Please see below instructions for using a custom service.
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 a refresh token 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}},
},
},
)
Polytope compatibility (~/.polytopeapirc)
When authenticating with get_token("polytope"), the library automatically writes the
refresh token to ~/.polytopeapirc as JSON ({"user_key": "..."}), matching the
expected Polytope client format.
Custom services
You can authenticate against a custom service by passing the path to a YAML config file:
from destinepyauth import get_token
result = get_token(config_path="/path/to/myservice.yaml")
token = result.access_token
where the config file should be in the following format:
# Example: myservice.yaml
scope: openid offline_access
iam_client: myservice-public
iam_redirect_uri: https://myservice.destine.eu/
# Optional: Token exchange configuration (only if needed)
exchange_config:
token_url: https://identity.example.com/token
audience: myservice-public
subject_issuer: desp-oidc
client_id: myservice-public
Service Configuration Fields
scope: OAuth2 scopes (e.g.,"openid","openid offline_access")iam_client: Client ID registered with the IAM (Identity and Access Management)iam_redirect_uri: OAuth redirect URI for the serviceiam_url(optional): IAM server URL (defaults tohttps://auth.destine.eu)iam_realm(optional): IAM realm (defaults todesp)
Some services (like Highway and HDA) require token exchange because they validate tokens against a different issuer than the initial login. For these services, an exchange_config section is necessary:
token_url: Token exchange endpointaudience: Target audience for the exchanged tokensubject_issuer: Subject issuer identifierclient_id: Client ID for the exchange request
The library automatically handles token exchange using RFC 8693 when exchange_config is present.
CLI Usage
# Built-in service
destinepyauth -s highway --print
# Custom service config file
destinepyauth -c path/to/myservice.yaml --print
Credential Handling
When you call get_token(), the library will prompt for your credentials. The password
uses masked input - nothing you type will be visible on screen:
from destinepyauth import get_token
result = get_token("highway")
# Username: myuser
# Password: (hidden input)
This ensures the password cannot be accidentally exposed in terminal logs, screen recordings, or shell history.
You can also provide credentials via environment variables to avoid interactive prompts:
export DESPAUTH_USER='<your-username>'
export DESPAUTH_PASSWORD='<your-password>'
When DESPAUTH_USER and DESPAUTH_PASSWORD are set, get_token() uses them directly.
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 DESP account settings.
Configuration
Service configurations are stored in YAML files in the destinepyauth/configs/ directory. Each service has its own configuration file (e.g., highway.yaml, cacheb.yaml) that defines default values for authentication parameters.
Configuration Priority
The library uses Conflator to merge configuration values.
The base configuration file is:
- Built-in service YAML (
destinepyauth/configs/{service}.yaml) when usingget_token("service")ordestinepyauth -s service - Your custom YAML when using
get_token(config_path=...)ordestinepyauth -c ...
Environment variables (DESPAUTH_*) override values from that base config file.
If both a service and a custom config path are provided (for example, destinepyauth -s hda -c config.yaml),
the custom config file is used as the base configuration.
Adding a new service
To integrate a new DestinE service, either:
- Fork the repository, add a new configuration file to
destinepyauth/configs/{service_name}.yaml, and then open a pull request - OR open an issue with a request to integrate a new service
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 destinepyauth-1.3.1.tar.gz.
File metadata
- Download URL: destinepyauth-1.3.1.tar.gz
- Upload date:
- Size: 161.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c6870f9c47d037ea6f445b033400e073cc03639c5956dd5050ec1f54a1630b1
|
|
| MD5 |
0c0f337ede29b2df52e3118a7584de52
|
|
| BLAKE2b-256 |
fea3254a76fd6083152f66713a528987b92f14a0ce29bf8343c4ec4357cbeb31
|
Provenance
The following attestation bundles were made for destinepyauth-1.3.1.tar.gz:
Publisher:
cd.yml on SercoSPA/DestinE-Platform-AuthN
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
destinepyauth-1.3.1.tar.gz -
Subject digest:
0c6870f9c47d037ea6f445b033400e073cc03639c5956dd5050ec1f54a1630b1 - Sigstore transparency entry: 1392778294
- Sigstore integration time:
-
Permalink:
SercoSPA/DestinE-Platform-AuthN@a1bce78f832a32fdcd5b090b8ca15f9eba26ae00 -
Branch / Tag:
refs/tags/v1.3.1 - Owner: https://github.com/SercoSPA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@a1bce78f832a32fdcd5b090b8ca15f9eba26ae00 -
Trigger Event:
push
-
Statement type:
File details
Details for the file destinepyauth-1.3.1-py3-none-any.whl.
File metadata
- Download URL: destinepyauth-1.3.1-py3-none-any.whl
- Upload date:
- Size: 21.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a3f2b2cac1bc4cae6ddf2f1d13d692378f9070a9827b189bbea9ec0c5140a4d
|
|
| MD5 |
42bc6fb2bd809787303551a6b5d46206
|
|
| BLAKE2b-256 |
a4180bf2dddfb015243afe0cdd4451a78306da8859dbc231a8dd7149cf4ebd82
|
Provenance
The following attestation bundles were made for destinepyauth-1.3.1-py3-none-any.whl:
Publisher:
cd.yml on SercoSPA/DestinE-Platform-AuthN
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
destinepyauth-1.3.1-py3-none-any.whl -
Subject digest:
1a3f2b2cac1bc4cae6ddf2f1d13d692378f9070a9827b189bbea9ec0c5140a4d - Sigstore transparency entry: 1392778316
- Sigstore integration time:
-
Permalink:
SercoSPA/DestinE-Platform-AuthN@a1bce78f832a32fdcd5b090b8ca15f9eba26ae00 -
Branch / Tag:
refs/tags/v1.3.1 - Owner: https://github.com/SercoSPA
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@a1bce78f832a32fdcd5b090b8ca15f9eba26ae00 -
Trigger Event:
push
-
Statement type: