diff options
author | Frederick Muriuki Muriithi | 2024-04-24 06:09:36 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-04-24 06:09:36 +0300 |
commit | 2af5b44537711c1f9d6bde9807f0eda515ffe30e (patch) | |
tree | 0d836d3d6807ee6307d6a16705d7710fa759ffdf /gn2/wqflask/oauth2 | |
parent | 06abdb22af872a8b909d53612283a33404359ba7 (diff) | |
download | genenetwork2-2af5b44537711c1f9d6bde9807f0eda515ffe30e.tar.gz |
DEBUG: log out request details
There is a failure on CI/CD that is not obvious - the logs should help
with debugging the issue.
Diffstat (limited to 'gn2/wqflask/oauth2')
-rw-r--r-- | gn2/wqflask/oauth2/toplevel.py | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/gn2/wqflask/oauth2/toplevel.py b/gn2/wqflask/oauth2/toplevel.py index a1e9196d..6b3db201 100644 --- a/gn2/wqflask/oauth2/toplevel.py +++ b/gn2/wqflask/oauth2/toplevel.py @@ -26,23 +26,6 @@ def register_client(): @toplevel.route("/code", methods=["GET"]) def authorisation_code(): """Use authorisation code to get token.""" - def __error__(error): - flash(f"{error['error']}: {error['error_description']}", - "alert-danger") - return redirect("/") - - def __success__(token): - session.set_user_token(token) - udets = user_details() - session.set_user_details({ - "user_id": uuid.UUID(udets["user_id"]), - "name": udets["name"], - "email": udets["email"], - "token": session.user_token(), - "logged_in": True - }) - return redirect("/") - code = request.args.get("code", "") if bool(code): base_url = urlparse(request.base_url, scheme=request.scheme) @@ -71,6 +54,27 @@ def authorisation_code(): key=jwtkey), "client_id": app.config["OAUTH2_CLIENT_ID"] } + + def __error__(error): + flash(f"{error['error']}: {error['error_description']}", + "alert-danger") + app.logger.debug("Request error (%s) %s: %s", + error["status_code"], error["error_description"], + request_data) + return redirect("/") + + def __success__(token): + session.set_user_token(token) + udets = user_details() + session.set_user_details({ + "user_id": uuid.UUID(udets["user_id"]), + "name": udets["name"], + "email": udets["email"], + "token": session.user_token(), + "logged_in": True + }) + return redirect("/") + return no_token_post( "auth/token", data=request_data).either( lambda err: __error__(process_error(err)), __success__) |