Skip to content

oauth

oauth

get_oauth_account_by_id async

get_oauth_account_by_id(
    auth: DomoAuth,
    account_id: int | str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Retrieve a specific OAuth account by ID.

Note: This function retrieves all OAuth accounts and filters to the selected one, as there doesn't appear to be a direct API for retrieving a single OAuth account.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object for API requests

required
account_id int | str

The ID of the OAuth account to retrieve

required
return_raw bool

Return raw response without processing

False
context RouteContext | None

RouteContext for request configuration

None

Returns:

Type Description
ResponseGetData

ResponseGetData object containing OAuth account metadata

Raises:

Type Description
AccountNoMatchError

If OAuth account is not found

Account_GET_Error

If OAuth account retrieval fails

Source code in src/crew_dcs/routes/account/oauth.py
 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
112
113
114
115
116
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(result_processor=ResponseGetDataProcessor()),
)
async def get_oauth_account_by_id(
    auth: DomoAuth,
    account_id: int | str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Retrieve a specific OAuth account by ID.

    Note: This function retrieves all OAuth accounts and filters to the selected one,
    as there doesn't appear to be a direct API for retrieving a single OAuth account.

    Args:
        auth: Authentication object for API requests
        account_id: The ID of the OAuth account to retrieve
        return_raw: Return raw response without processing
        context: RouteContext for request configuration

    Returns:
        ResponseGetData object containing OAuth account metadata

    Raises:
        AccountNoMatchError: If OAuth account is not found
        Account_GET_Error: If OAuth account retrieval fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    res = await get_oauth_accounts(
        auth=auth,
        return_raw=return_raw,
        context=context,
    )

    if return_raw:
        return res

    # Convert account_id to int for comparison if it's a string
    target_id = int(account_id) if isinstance(account_id, str) else account_id
    res.response = next((obj for obj in res.response if obj["id"] == target_id), None)

    if not res.response:
        raise AccountNoMatchError(account_id=str(account_id), res=res)

    return res

get_oauth_accounts async

get_oauth_accounts(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Retrieve all OAuth accounts the user has access to.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object for API requests

required
return_raw bool

Return raw response without processing

False
context RouteContext | None

RouteContext for request configuration

None

Returns:

Type Description
ResponseGetData

ResponseGetData object containing OAuth account list

Raises:

Type Description
Account_GET_Error

If OAuth account retrieval fails

Source code in src/crew_dcs/routes/account/oauth.py
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
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(result_processor=ResponseGetDataProcessor()),
)
async def get_oauth_accounts(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Retrieve all OAuth accounts the user has access to.

    Args:
        auth: Authentication object for API requests
        return_raw: Return raw response without processing
        context: RouteContext for request configuration

    Returns:
        ResponseGetData object containing OAuth account list

    Raises:
        Account_GET_Error: If OAuth account retrieval fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/data/v1/accounts/templates/user/extended"

    res = await gd.get_data(
        auth=auth,
        url=url,
        method="GET",
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise Account_GET_Error(res=res)
    return res