aboutsummaryrefslogtreecommitdiff
path: root/gn2
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-04-30 10:14:34 +0300
committerBonfaceKilz2024-04-30 13:09:46 +0300
commit5e54afe8fc7fbe0da42a0d8b477c60599f9b967b (patch)
tree4545ba11a582ad1575853997d49569e62a42ba97 /gn2
parent182376c1a06c95e67ae30aad6d9d4baf32af7910 (diff)
downloadgenenetwork2-5e54afe8fc7fbe0da42a0d8b477c60599f9b967b.tar.gz
Make returning an json object from oauth2_get optional.
* gn2/wqflask/oauth2/client.py (oauth2_get): Add a jsonify_p key word that defaults to False. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'gn2')
-rw-r--r--gn2/wqflask/oauth2/client.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/gn2/wqflask/oauth2/client.py b/gn2/wqflask/oauth2/client.py
index 8feb9c7f..c16b705d 100644
--- a/gn2/wqflask/oauth2/client.py
+++ b/gn2/wqflask/oauth2/client.py
@@ -58,7 +58,8 @@ def __no_token__(_err) -> Left:
resp.status_code = 400
return Left(resp)
-def oauth2_get(uri_path: str, data: dict = {}, **kwargs) -> Either:
+def oauth2_get(uri_path: str, data: dict = {},
+ jsonify_p: bool = False, **kwargs) -> Either:
def __get__(token) -> Either:
client = OAuth2Session(
oauth2_clientid(), oauth2_clientsecret(),
@@ -68,6 +69,8 @@ def oauth2_get(uri_path: str, data: dict = {}, **kwargs) -> Either:
data=data,
**kwargs)
if resp.status_code == 200:
+ if jsonify_p:
+ return Right(resp)
return Right(resp.json())
return Left(resp)