Albert Client Credentials
albert.AlbertClientCredentials
Bases: BaseAlbertModel
, AuthManager
Client credentials manager for programmatic OAuth2 access to the Albert API.
This class implements the OAuth2 Client Credentials flow, allowing automated (non-interactive) systems to authenticate securely using a client ID and secret.
Attributes:
Name | Type | Description |
---|---|---|
id |
str
|
The client ID used for authentication. |
secret |
SecretStr
|
The client secret used for authentication. |
base_url |
str
|
The base URL of the Albert API. |
Usage
Show JSON schema:
{
"description": "Client credentials manager for programmatic OAuth2 access to the Albert API.\n\nThis class implements the OAuth2 Client Credentials flow, allowing automated\n(non-interactive) systems to authenticate securely using a client ID and secret.\n\nAttributes\n----------\nid : str\n The client ID used for authentication.\nsecret : SecretStr\n The client secret used for authentication.\nbase_url : str\n The base URL of the Albert API.\n\nUsage\n-----\n```\ncreds = AlbertClientCredentials(\n id=\"your-client-id\",\n secret=SecretStr(\"your-client-secret\"),\n base_url=\"https://app.albertinvent.com\",\n)\nclient = Albert(auth_manager=creds)\nclient.roles.get_all()\n```",
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"secret": {
"format": "password",
"title": "Secret",
"type": "string",
"writeOnly": true
},
"base_url": {
"title": "Base Url",
"type": "string"
}
},
"required": [
"id",
"secret"
],
"title": "AlbertClientCredentials",
"type": "object"
}
Fields:
-
_token_info
(OAuthTokenInfo | None
) -
_refresh_time
(datetime | None
) -
id
(str
) -
secret
(SecretStr
) -
base_url
(str
)
from_env
from_env(
*,
base_url_env: str = "ALBERT_BASE_URL",
client_id_env: str = "ALBERT_CLIENT_ID",
client_secret_env: str = "ALBERT_CLIENT_SECRET",
) -> AlbertClientCredentials | None
Create AlbertClientCredentials
from environment variables.
Returns None if any of the required environment variables are missing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url_env
|
str
|
Name of the environment variable containing the base URL (defaults to "ALBERT_BASE_URL"). |
'ALBERT_BASE_URL'
|
client_id_env
|
str
|
Name of the environment variable containing the client ID (defaults to "ALBERT_CLIENT_ID"). |
'ALBERT_CLIENT_ID'
|
client_secret_env
|
str
|
Name of the environment variable containing the client secret (defaults to "ALBERT_CLIENT_SECRET"). |
'ALBERT_CLIENT_SECRET'
|
Returns:
Type | Description |
---|---|
AlbertClientCredentials | None
|
The credentials instance if all environment variables are present; otherwise, None. |