From 04846aac0e2ac092440f165b544ad2c191f88452 Mon Sep 17 00:00:00 2001 From: tuxcoder Date: Sat, 23 Dec 2023 02:41:39 +0100 Subject: [PATCH] better ory-hydra error handling --- lenticular_cloud/views/oauth2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lenticular_cloud/views/oauth2.py b/lenticular_cloud/views/oauth2.py index c1320bb..3767731 100644 --- a/lenticular_cloud/views/oauth2.py +++ b/lenticular_cloud/views/oauth2.py @@ -1,5 +1,5 @@ from authlib.integrations.flask_client import OAuth -from authlib.integrations.base_client.errors import MismatchingStateError +from authlib.integrations.base_client.errors import MismatchingStateError, OAuthError from flask import Flask, Blueprint, Response, session, request, redirect, url_for from flask_login import login_user, logout_user, current_user from flask.typing import ResponseReturnValue @@ -43,6 +43,9 @@ def authorized() -> ResponseReturnValue: except MismatchingStateError: logger.warning("MismatchingStateError redirect user") return redirect(url_for('oauth2.login')) + except OAuthError as e: + logger.warning(f"OAuthError redirect user {e}") + return redirect(url_for('oauth2.login')) if token is None: return 'bad request', 400 session['token'] = token