Skip to content

Commit a4f7b4e

Browse files
committed
Improve token exchange error logging
1 parent a024ec3 commit a4f7b4e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

images/dashboard/src/routes/login_routes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from fastapi.templating import Jinja2Templates
88
from sqlalchemy.orm import Session
99
from fastapi.responses import JSONResponse, RedirectResponse
10+
from oauthlib.oauth2.rfc6749.errors import MissingTokenError
1011
from requests_oauthlib import OAuth2Session
1112
from models.sessions import Sessions
1213
from datetime import datetime, timedelta, timezone
@@ -182,8 +183,11 @@ async def redirect_sandbox(request: Request, code: str, state: str = None, db: S
182183
else:
183184
logging.error("State parameter not found")
184185
raise HTTPException(status_code=400, detail="Missing state parameter")
185-
except Exception as e:
186-
logging.error(f"An error occurred: {e}")
186+
except MissingTokenError as e:
187+
logging.error(f"Token exchange failed: {e.description} | Response body: {e.response}")
188+
raise HTTPException(status_code=500, detail="Internal Server Error")
189+
except Exception:
190+
logging.exception("An error occurred during sandbox redirect")
187191
raise HTTPException(status_code=500, detail="Internal Server Error")
188192

189193

0 commit comments

Comments
 (0)