Skip to content

Commit 1e33f2c

Browse files
committed
feat: updated error handling on auth component
1 parent ec9ca07 commit 1e33f2c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/auth.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any, Dict
22
import httpx
33
import jwt
4-
from fastapi import Depends, HTTPException, WebSocket, status
4+
from fastapi import Depends, WebSocket, status
55
from fastapi.security import OAuth2AuthorizationCodeBearer
66
from jwt import PyJWKClient
77
from loguru import logger
@@ -96,15 +96,15 @@ async def exchange_token_for_provider(
9696
9797
:return: The token response (dict) on success.
9898
99-
:raise: Raises HTTPException with an appropriate status and message on error.
99+
:raise: Raises AuthException with an appropriate status and message on error.
100100
"""
101101
token_url = f"{KEYCLOAK_BASE_URL}/protocol/openid-connect/token"
102102

103103
# Check if the necessary settings are in place
104104
if not settings.keycloak_client_id or not settings.keycloak_client_secret:
105-
raise HTTPException(
106-
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
107-
detail="Token exchange not configured on the server (missing client credentials).",
105+
raise AuthException(
106+
http_status=status.HTTP_500_INTERNAL_SERVER_ERROR,
107+
message="Token exchange not configured on the server (missing client credentials).",
108108
)
109109

110110
payload = {

0 commit comments

Comments
 (0)