Skip to main content

Destinelab Python package

Project description

DestinE Auth

DestinE Auth is a helper package that simplifies authentication for DestinE workflows:

  1. Authenticate with DESP credentials.
  2. Get a DESP access token. (Normally transparent for the user)
  3. Exchange that token for a DEDL access token.

A Destination Earth - Data Lake access token is necessary to interact with Destination Earth - Data Lake APIs and services.

Install

pip install destinelab

Note: Python compatibility: 3.8+

Quick usage

  • Here's a quick example of how to use the AuthHandler to get a DEDL token using DESP credentials. This is the recommended approach for most users, as it handles caching and token refresh automatically.
from destinelab import AuthHandler

handler = AuthHandler("DESP_USERNAME", "DESP_PASSWORD")
dedl_token = handler.get_token()

auth_headers = {"Authorization": f"Bearer {dedl_token}"} # Example of how to use the token in API requests

Logging and debug level

By default, the package is quiet and does not configure global logging. To enable debug output for troubleshooting, configure the package logger explicitly:

import logging
from destinelab import configure_logging

configure_logging(level=logging.DEBUG)

You can set INFO, WARNING, ERROR, or DEBUG depending on how much detail you need.

Service account usage (client credentials)

from destinelab import DEDLServiceAccountAuth

dedl_token = DEDLServiceAccountAuth(
	client_id="YOUR_CLIENT_ID",
	client_secret="YOUR_CLIENT_SECRET",
).get_token()

Check roles and DT access

  • AuthHandler also provides helper methods to check the roles associated with the token and whether DT access is allowed, which can be useful for debugging or conditional logic in your application.
from destinelab import AuthHandler

handler = AuthHandler("DESP_USERNAME", "DESP_PASSWORD")
dedl_token = handler.get_token()
roles = handler.get_roles(dedl_token)
is_dt_access_allowed = handler.is_DTaccess_allowed(dedl_token)

DESP and DEDL token exchange (i.e. breaking the process down into individual steps)

  • This is not recommended or useful for typical users, but can be useful for debugging or if you need more control over the individual steps.
from destinelab import DESPAuth, DEDLAuth

desp_token = DESPAuth("DESP_USERNAME", "DESP_PASSWORD").get_desp_token()
dedl_token = DEDLAuth(desp_token).get_token()

Error behavior

  • DESPAuth.get_desp_token() raises explicit auth errors (for example invalid credentials, OTP required, network failures, and DESP token exchange failures).
  • DEDLAuth.get_token() raises explicit exceptions on exchange failure.
  • DEDLServiceAccountAuth.get_token() raises explicit exceptions on service-account authentication failure.
  • AuthHandler.get_token() first checks whether an already stored DEDL token is still valid (verified against DEDL Keycloak JWKS). If valid, it is returned immediately; otherwise it composes DESPAuth -> DEDLAuth using DESP user credentials.
  • If cached-token validation cannot be completed because the validator backend is unavailable (for example metadata/JWKS lookup issues), AuthHandler.get_token() logs a warning and continues with a refresh flow (DESPAuth -> DEDLAuth).

License

This project is licensed under MIT. See LICENSE.

MIT License

Copyright (c) 2025 Patryk Grzybowski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

destinelab-1.14.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

destinelab-1.14-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file destinelab-1.14.tar.gz.

File metadata

  • Download URL: destinelab-1.14.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for destinelab-1.14.tar.gz
Algorithm Hash digest
SHA256 18c980dbb2d7c41f9d2ee6cf617f664998dd26d5a1a019ba6dda129f18787297
MD5 fc3313ea7cdd87d2a10dd8a2650e8a96
BLAKE2b-256 cbf0bc7b5bf8961ac49f1a9cb676460ce251d1a9d74dffcf91957225972cbb5a

See more details on using hashes here.

File details

Details for the file destinelab-1.14-py3-none-any.whl.

File metadata

  • Download URL: destinelab-1.14-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for destinelab-1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 23cf550465bbe485050d7261f580cb8f01dbd1c33ab8141c6b1741a8fff08918
MD5 977d2efa7220f2cf43d4771b111efe9b
BLAKE2b-256 fdaaae45e59bba4bc2dd8ac4cd2f22c6d826eddd98f4b01e22c7e2ef154d7225

See more details on using hashes here.

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