From 9fa6ad2949dfe9698435e6c4c6b64178bfcf81fe Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Tue, 31 Mar 2026 17:56:26 -0400 Subject: [PATCH] handle exception in oauth_callback --- main.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 3211a65..9f4ca16 100644 --- a/main.py +++ b/main.py @@ -532,13 +532,17 @@ def oauth_callback() -> WerkzeugResponse: return redirect(url_for("index")) client_id, redirect_uri = compute_client_id(request.url_root) - tokens, dpop_authserver_nonce = initial_token_request( - row, - code, - client_id, - redirect_uri, - CLIENT_SECRET_JWK, - ) + try: + tokens, dpop_authserver_nonce = initial_token_request( + row, + code, + client_id, + redirect_uri, + CLIENT_SECRET_JWK, + ) + except Exception: + flash("Login failed — could not complete token exchange. Try again.", "error") + return redirect(url_for("index")) if row["did"]: # type: ignore[index] did, handle, pds_url = row["did"], row["handle"], row["pds_url"] # type: ignore[index] -- 2.51.2