Skip to content

token

token

Token-based authentication classes for Domo (access tokens).

DomoTokenAuth dataclass

DomoTokenAuth(
    domo_access_token: str,
    domo_instance: str,
    token_name: str | None = None,
    token: str | None = None,
    user_id: str | None = None,
    is_valid_token: bool = False,
    cache_responses: bool = False,
    cache_size: int = 1000,
    cache_default_ttl: int = 300,
    cache_strategy: str | None = None,
    custom_cache_rules: dict[str, list[str]] | None = None,
)

Bases: DomoAuth

Token-based authentication using pre-generated access tokens.

This authentication method uses access tokens generated from Domo's admin panel (Admin > Access Tokens). This is particularly useful in environments where direct username/password authentication is not permitted or for automated systems.

Attributes:

Name Type Description
domo_access_token str

Pre-generated access token (not shown in repr)

domo_instance str

The Domo instance identifier

token_name str | None

Name identifier for the token

token str | None

The authentication token (not shown in repr)

user_id str | None

The authenticated user's ID

is_valid_token bool

Whether the current token is valid

cache_responses bool

Enable HTTP response caching (default: False)

cache_size int

Maximum number of cache entries (default: 1000)

cache_default_ttl int

Default cache TTL in seconds (default: 300)

cache_strategy str | None

Cache invalidation strategy (default: None, uses SMART)

custom_cache_rules dict | None

Custom cache invalidation rules (default: None)

Example

auth = DomoTokenAuth( ... domo_access_token="your-access-token-here", ... domo_instance="mycompany" ... ) token = await auth.get_auth_token()

auth_header property

auth_header: dict

Generate the authentication header for access token based authentication.

get_auth_token async

get_auth_token(
    token_name: str | None = None, **context_kwargs
) -> str

Retrieve the access token, updating internal attributes as necessary.

Source code in src/crew_dcs/auth/token.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
@log_call(
    level_name="auth",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def get_auth_token(
    self,
    token_name: str | None = None,
    **context_kwargs,
) -> str:
    """Retrieve the access token, updating internal attributes as necessary."""
    if not self.user_id:
        await self.who_am_i(**context_kwargs)

    self.token = self.domo_access_token
    self.is_valid_token = True

    if token_name:
        self.token_name = token_name

    return self.token