From 936a6487c2e4f129580f629e03e29696410aadd2 Mon Sep 17 00:00:00 2001 From: roland Date: Mon, 31 Jan 2022 11:18:28 +0100 Subject: [PATCH] Response might not be a Message instance. --- src/oidcop/endpoint.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/oidcop/endpoint.py b/src/oidcop/endpoint.py index 854b85ae..2b98815f 100755 --- a/src/oidcop/endpoint.py +++ b/src/oidcop/endpoint.py @@ -1,3 +1,4 @@ +import json import logging from typing import Callable from typing import Optional @@ -363,7 +364,10 @@ def do_response( if self.response_placement == "body": if self.response_format == "json": content_type = "application/json; charset=utf-8" - resp = _response.to_json() + if isinstance(_response, Message): + resp = _response.to_json() + else: + resp = json.dumps(_response) elif self.response_format in ["jws", "jwe", "jose"]: content_type = "application/jose; charset=utf-8" resp = _response