Config Class
TheConfig dataclass holds all configuration parameters:
Parameters
uri(str) - Base URL of the ECA API (e.g.,http://localhost:2580/v1)api_token(str, optional) - Pre-existing session tokenusername(str, optional) - Username for authenticationpassword(str, optional) - Password for authentication
Authentication Methods
Username and Password
When you initialize theECA class with username and password, it automatically performs a login to retrieve an API token:
API Token
If you already have a session token, you can provide it directly:Authentication Flow
TheECA class handles authentication automatically:
- If
api_tokenis provided and not empty, it uses the token directly - If
api_tokenis empty, it performs a login usingusernameandpassword - The retrieved session token is stored in
config.api_token - All subsequent API calls use this token
avenieca/api/eca.py:14-21:
AuthResponse Model
Successful login returns anAuthResponse object:
Example with Environment Variables
Security Best Practices
- Store credentials in environment variables, not in code
- Use API tokens when possible to avoid repeated logins
- Rotate tokens regularly
- Never commit credentials to version control