Skip to content

Commit d1524f6

Browse files
committed
map 400 to 401 on s2s
1 parent 2784a58 commit d1524f6

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

  • src/uipath_llm_client/settings/llmgateway

src/uipath_llm_client/settings/llmgateway/auth.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from collections.abc import Generator
22

3-
from httpx import Auth, Client, HTTPStatusError, Request, Response
3+
from httpx import Auth, Client, Request, Response
44

55
from uipath_llm_client.settings.llmgateway.settings import LLMGatewayBaseSettings
66
from uipath_llm_client.settings.llmgateway.utils import LLMGatewayEndpoints
77
from uipath_llm_client.settings.utils import SingletonMeta
8-
from uipath_llm_client.utils.exceptions import UiPathAPIError
8+
from uipath_llm_client.utils.exceptions import UiPathAPIError, UiPathAuthenticationError
99

1010

1111
class LLMGatewayS2SAuth(Auth, metaclass=SingletonMeta):
@@ -39,10 +39,15 @@ def get_llmgw_token_header(
3939
)
4040
with Client() as http_client:
4141
response = http_client.post(url_get_token, data=token_credentials)
42-
try:
43-
response.raise_for_status()
44-
except HTTPStatusError as e:
45-
raise UiPathAPIError.from_response(e.response)
42+
if response.is_client_error:
43+
raise UiPathAuthenticationError(
44+
message="Failed to authenticate with LLM Gateway, invalid credentials",
45+
request=response.request,
46+
response=response,
47+
body=response.json(),
48+
)
49+
elif response.is_error:
50+
raise UiPathAPIError.from_response(response)
4651
llmgw_token_header = response.json().get("access_token")
4752
return llmgw_token_header
4853

0 commit comments

Comments
 (0)