AQIT
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
cloud_auth.py
Go to the documentation of this file.
1
# Copyright (c) 2025-present Aquin Labs Private Limited. All Rights Reserved.
2
"""Aquin cloud HTTP auth error helpers."""
3
from
__future__
import
annotations
4
5
import
httpx
6
7
8
def
cloud_auth_error_exit
(api_key: str |
None
=
None
) ->
None
:
9
"""Print a clear login hint and exit when Aquin cloud rejects the API key."""
10
from
aquin.auth_config
import
print_token_rejected, resolve_api_key
11
12
print_token_rejected(api_key
or
resolve_api_key(allow_missing=
True
)
or
None
)
13
14
15
def
is_cloud_auth_failure
(exc: BaseException) -> bool:
16
if
isinstance(exc, httpx.HTTPStatusError)
and
exc.response
is
not
None
:
17
return
exc.response.status_code
in
(401, 403)
18
msg = str(exc).lower()
19
return
"401"
in
msg
or
"403"
in
msg
or
"unauthorized"
in
msg
20
21
22
def
exit_if_cloud_auth_error
(exc: BaseException) ->
None
:
23
"""Exit with a clear login hint when Aquin cloud rejects the API key."""
24
if
is_cloud_auth_failure
(exc):
25
cloud_auth_error_exit
()
aquin.auth_config
Definition
auth_config.py:1
aquin.cloud_auth.is_cloud_auth_failure
bool is_cloud_auth_failure(BaseException exc)
Definition
cloud_auth.py:19
aquin.cloud_auth.exit_if_cloud_auth_error
None exit_if_cloud_auth_error(BaseException exc)
Definition
cloud_auth.py:26
aquin.cloud_auth.cloud_auth_error_exit
None cloud_auth_error_exit(str|None api_key=None)
Definition
cloud_auth.py:12
aquin
cloud_auth.py
AQIT · Aquin Labs Private Limited · Apache 2.0 · Generated by
1.18.0