Auth

dapi.auth.init(base_url='https://designsafe.tapis.io', username=None, password=None, env_file=None)[source]

Initialize and authenticate a Tapis client for DesignSafe.

Creates and authenticates a Tapis client instance for interacting with DesignSafe resources. The function follows a credential resolution hierarchy and handles secure password input when needed.

Credential Resolution Order:
  1. Explicitly passed username/password arguments

  2. Environment variables (DESIGNSAFE_USERNAME, DESIGNSAFE_PASSWORD) - Loads from env_file if specified, otherwise checks system environment

  3. Interactive prompts for missing credentials

Parameters:
  • base_url (str, optional) – The Tapis base URL for DesignSafe API endpoints. Defaults to “https://designsafe.tapis.io”.

  • username (str, optional) – Explicit DesignSafe username. If None, will attempt to load from environment or prompt user. Defaults to None.

  • password (str, optional) – Explicit DesignSafe password. If None, will attempt to load from environment or prompt user securely. Defaults to None.

  • env_file (str, optional) – Path to a .env file containing credentials. If None, attempts to load from default .env file if it exists. Defaults to None.

Returns:

An authenticated tapipy.Tapis client object ready for API calls.

Return type:

Tapis

Raises:

AuthenticationError – If authentication fails due to invalid credentials, network issues, or if required credentials cannot be obtained.

Example

>>> # Using explicit credentials
>>> client = init(username="myuser", password="mypass")
Authentication successful.
>>> # Using environment variables or .env file
>>> client = init(env_file=".env")
Authentication successful.
>>> # Interactive authentication
>>> client = init()
Enter DesignSafe Username: myuser
Enter DesignSafe Password: [hidden]
Authentication successful.

Note

The function disables automatic spec downloads for faster initialization. Password input uses getpass for secure entry in terminal environments.