Auth
Authentication and credential management for DesignSafe access.
Authentication
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
- Explicitly passed username/password arguments
- Environment variables (DESIGNSAFE_USERNAME, DESIGNSAFE_PASSWORD)
- Loads from env_file if specified, otherwise checks system environment
- Interactive prompts for missing credentials
PARAMETER | DESCRIPTION |
---|---|
base_url
|
The Tapis base URL for DesignSafe API endpoints. Defaults to "https://designsafe.tapis.io".
TYPE:
|
username
|
Explicit DesignSafe username. If None, will attempt to load from environment or prompt user. Defaults to None.
TYPE:
|
password
|
Explicit DesignSafe password. If None, will attempt to load from environment or prompt user securely. Defaults to None.
TYPE:
|
env_file
|
Path to a .env file containing credentials. If None, attempts to load from default .env file if it exists. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tapis
|
An authenticated tapipy.Tapis client object ready for API calls.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
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.
Source code in dapi/auth.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|