Skip to content

developer

developer

Developer authentication classes for Domo (OAuth2 client credentials).

DomoDeveloperAuth dataclass

DomoDeveloperAuth(
    domo_client_id: str,
    domo_client_secret: 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

Developer authentication using client credentials.

This authentication method uses OAuth2 client credentials (client ID and secret) to obtain bearer tokens. This is typically used for applications built on Domo's developer platform and requires developer app registration.

Attributes:

Name Type Description
domo_client_id str

OAuth2 client ID from developer app registration

domo_client_secret str

OAuth2 client secret (not shown in repr)

domo_instance str

The Domo instance identifier

token_name str | None

Name identifier for the token

token str | None

The bearer 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 = DomoDeveloperAuth( ... domo_client_id="your-client-id", ... domo_client_secret="", # pragma: allowlist secret ... domo_instance="mycompany" ... ) token = await auth.get_auth_token()

auth_header property

auth_header: dict

Generate the authentication header for developer token authentication.

get_auth_token async

get_auth_token(**context_kwargs) -> str

Retrieve the developer token using client credentials and update internal attributes.

Source code in src/crew_dcs/auth/developer.py
 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
112
113
114
115
116
117
118
119
120
121
@log_call(
    level_name="auth",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def get_auth_token(
    self,
    **context_kwargs,
) -> str:
    """Retrieve the developer token using client credentials and update internal attributes."""
    from ..routes import auth as auth_routes

    res = await auth_routes.get_developer_auth(
        auth=None,
        domo_client_id=self.domo_client_id,
        domo_client_secret=self.domo_client_secret,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )

    if isinstance(res, ResponseGetData) and res.is_success and res.response:
        self.is_valid_token = True
        self.token = str(
            res.response.get("access_token", "")
            if isinstance(res.response, dict)
            else ""
        )
        self.user_id = (
            res.response.get("userId") if isinstance(res.response, dict) else ""
        )
        if isinstance(self.user_id, int):
            self.user_id = str(self.user_id)
        self.domo_instance = (
            res.response.get("domain", self.domo_instance)
            if isinstance(res.response, dict)
            else ""
        )
        self.token_name = self.token_name or "developer_auth"
        return self.token

    raise AuthError(message="Failed to retrieve developer token")

who_am_i async

who_am_i(**context_kwargs) -> ResponseGetData

Use cached user_id from get_auth_token response (no separate API call).

Source code in src/crew_dcs/auth/developer.py
123
124
125
126
127
128
129
130
131
132
133
134
async def who_am_i(
    self,
    **context_kwargs,
) -> ResponseGetData:
    """Use cached user_id from get_auth_token response (no separate API call)."""
    if not self.user_id:
        await self.get_auth_token(**context_kwargs)
    return ResponseGetData(
        status=200,
        response={"id": self.user_id},
        is_success=True,
    )