From 5e54afe8fc7fbe0da42a0d8b477c60599f9b967b Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 30 Apr 2024 10:14:34 +0300 Subject: 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 --- gn2/wqflask/oauth2/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3