aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/oauth2
diff options
context:
space:
mode:
authorJohn Nduli2024-07-31 11:34:26 +0300
committerBonfaceKilz2024-09-17 11:37:43 +0300
commite86a6a9d254df6c041c14edcb15a03e7bdb73ee2 (patch)
treeb707a22034616a30cb367e96212787cc8274c73f /gn2/wqflask/oauth2
parentb09faa4b5055fd773891ed819f0503165167892e (diff)
downloadgenenetwork2-e86a6a9d254df6c041c14edcb15a03e7bdb73ee2.tar.gz
fix: dynamically get the keys that may contain error messages
Diffstat (limited to 'gn2/wqflask/oauth2')
-rw-r--r--gn2/wqflask/oauth2/request_utils.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/gn2/wqflask/oauth2/request_utils.py b/gn2/wqflask/oauth2/request_utils.py
index 167d0cbd..673a7da9 100644
--- a/gn2/wqflask/oauth2/request_utils.py
+++ b/gn2/wqflask/oauth2/request_utils.py
@@ -41,8 +41,10 @@ def process_error(error: Response,
if error.status_code in range(400, 500):
try:
err = error.json()
- msg = err.get(
- "error_message", err.get("error_description", f"{error.reason}"))
+ potential_keys = [key for key in err.keys() if key.startswith("error")]
+ msg = f"{error.reason}"
+ if potential_keys:
+ msg = " ; ".join([f"{k}: {err[k]}" for k in potential_keys])
except simplejson.errors.JSONDecodeError as _jde:
msg = message
return {