better ory-hydra error handling
This commit is contained in:
parent
632158b566
commit
04846aac0e
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue