DomoError Classes
source
NoAccessTokenReturned
NoAccessTokenReturned (function_name:Optional[str]=None,
status:Optional[int]=None, message:str='No
AccessToken returned',
domo_instance:Optional[str]=None,
parent_class:str=None)
base exception
source
InvalidInstanceError
InvalidInstanceError (function_name:Optional[str]=None,
parent_class:str=None, status:Optional[int]=None,
message='invalid instance',
domo_instance:Optional[str]=None)
return if invalid domo_instance sent to API
source
InvalidAuthTypeError
InvalidAuthTypeError (required_auth_type:dict=None,
required_auth_type_ls:list=None,
function_name:Optional[str]=None,
parent_class:str=None,
domo_instance:Optional[str]=None)
return invalid Auth type sent to API
source
AccountLockedError
AccountLockedError (function_name:Optional[str]=None,
status:Optional[int]=None, message='invalid
credentials', domo_instance:Optional[str]=None,
parent_class:str=None)
return invalid credentials sent to API
function_name |
Optional |
None |
|
status |
Optional |
None |
API request status |
message |
str |
invalid credentials |
|
domo_instance |
Optional |
None |
|
parent_class |
str |
None |
|
source
InvalidCredentialsError
InvalidCredentialsError (function_name:Optional[str]=None,
parent_class:str=None,
status:Optional[int]=None, message='invalid
credentials', domo_instance:Optional[str]=None)
return invalid credentials sent to API
function_name |
Optional |
None |
|
parent_class |
str |
None |
|
status |
Optional |
None |
API request status |
message |
str |
invalid credentials |
|
domo_instance |
Optional |
None |
|
source
AuthError
AuthError (**kwargs)
base exception
Authentication Routes
Stand alone functions for users who prefer a functional programming approach
Full Auth Route - username and password authentication
source
get_full_auth
get_full_auth (domo_instance:str, domo_username:str, domo_password:str,
auth:Any=None, session:Optional[httpx.AsyncClient]=None,
debug_api:bool=False, parent_class:str=None,
debug_num_stacks_to_drop=1, return_raw:bool=False)
uses username and password authentication to retrieve a full_auth access token
domo_instance |
str |
|
domo_instance.domo.com |
domo_username |
str |
|
email address |
domo_password |
str |
|
|
auth |
Any |
None |
|
session |
Optional |
None |
|
debug_api |
bool |
False |
|
parent_class |
str |
None |
|
debug_num_stacks_to_drop |
int |
1 |
|
return_raw |
bool |
False |
|
Returns |
ResponseGetData |
|
|
Sample Implementations of get_full_auth
intentional invalid credentials
try:
await get_full_auth(
domo_instance=os.environ['DOMO_INSTANCE'],
domo_username="test@test.com",
domo_password="fake password",
)
except (InvalidCredentialsError, AccountLockedError) as e:
print(e)
π InvalidCredentialsError π - function: wrapper || status 200 || INVALID_CREDENTIALS at domo-community
invalid instance
try:
await get_full_auth(
domo_instance="test",
domo_username="fake@test.com",
domo_password="fake password",
)
except InvalidInstanceError as e:
print(e)
π InvalidInstanceError π - function: wrapper || status 403 || Forbidden at test
valid credentials
await get_full_auth(
domo_instance=os.environ['DOMO_INSTANCE'],
domo_username=os.environ["DOMO_USERNAME"],
domo_password=os.environ["DOMO_PASSWORD"],
)
ResponseGetData(status=200, response={'userId': 1893952720, 'success': True, 'sessionToken': 'eyJjdXN0b21lcklkIjoibW1tbS0wMDEyLTAyMDAiLCJleHBpcmF0aW9uIjoxNzI5MTQ2NDU0MjA1LCJobWFjU2lnbmF0dXJlIjoiZTMzMGRiOTMzMDVjODkzZTkwZmQyYThmOWU4MWIzZDdiOTA1MTI3MmEwMzIxMWUzYjE5YmE5MDlkMDZkYzg4ZCIsInNpZCI6ImRhMjJjNTU5LTEwNTctNDE5NC05ZTJlLTM3YTIwODdhOWRlYiIsInRpbWVzdGFtcCI6MTcyOTExNzY1NDIwNSwidG9lcyI6IlVOS05PV05TSUQiLCJ1c2VySWQiOiIxODkzOTUyNzIwIn0%3D', 'twoFactorInfo': {'token': None, 'key': None, 'status': 'VALID', 'phoneMask': None}}, is_success=True, parent_class=None)
Developer Auth Route - client_id and secret authentication
source
get_developer_auth
get_developer_auth (domo_client_id:str, domo_client_secret:str,
auth:Any=None,
session:Optional[httpx.AsyncClient]=None,
debug_api:bool=False, parent_class:str=None,
debug_num_stacks_to_drop=1, return_raw:bool=False)
only use for authenticating against apis documented under developer.domo.com
Sample Implementations of get_developer_auth
The 401 response is expected because we are using invalid credentials
try:
await get_developer_auth(domo_client_id="test_id", domo_client_secret="test_secret", auth = None)
except InvalidCredentialsError as e:
print(e)
π InvalidCredentialsError π - function: wrapper || status 401 || Unauthorized
Who Am I?
source
who_am_i
who_am_i (auth:Any, domo_instance:str, auth_header:dict=None,
session:httpx.AsyncClient=None, parent_class:str=None,
debug_num_stacks_to_drop=0, debug_api:bool=False,
return_raw:bool=False)
will attempt to validate against the βmeβ API. This is the same authentication test the Domo Java CLI uses.
auth |
Any |
|
|
domo_instance |
str |
|
.domo.com |
auth_header |
dict |
None |
|
session |
AsyncClient |
None |
|
parent_class |
str |
None |
|
debug_num_stacks_to_drop |
int |
0 |
|
debug_api |
bool |
False |
|
return_raw |
bool |
False |
|
Sample implementation of who_am_i
test developer token
(await who_am_i(
auth = None,
domo_instance=os.environ['DOMO_INSTANCE'],
auth_header={"x-domo-developer-token": os.environ["DOMO_ACCESS_TOKEN"]},
debug_api=False,
return_raw=False,
)).response
{'id': 1893952720,
'invitorUserId': 587894148,
'displayName': 'Jae Wilson1',
'department': 'Business Improvement',
'userName': 'jae@onyxreporting.com',
'emailAddress': 'jae@datacrew.space',
'avatarKey': 'c605f478-0cd2-4451-9fd4-d82090b71e66',
'accepted': True,
'userType': 'USER',
'modified': 1729114351093,
'created': 1588960518,
'anonymous': False,
'systemUser': False,
'pending': False,
'active': True}
test full_auth token
res = await get_full_auth(
domo_instance=os.environ['DOMO_INSTANCE'],
domo_username=os.environ["DOMO_USERNAME"],
domo_password=os.environ["DOMO_PASSWORD"],
)
session_token = res.response.get("sessionToken")
(await who_am_i(
auth = None,
domo_instance=os.environ['DOMO_INSTANCE'],
auth_header={"x-domo-authentication": session_token}
)).response
{'id': 1893952720,
'invitorUserId': 587894148,
'displayName': 'Jae Wilson1',
'department': 'Business Improvement',
'userName': 'jae@onyxreporting.com',
'emailAddress': 'jae@datacrew.space',
'avatarKey': 'c605f478-0cd2-4451-9fd4-d82090b71e66',
'accepted': True,
'userType': 'USER',
'modified': 1729114351093,
'created': 1588960518,
'systemUser': False,
'anonymous': False,
'active': True,
'pending': False}