From a847df9e1dc4c4fcff6ffc30610499e3534fd07e Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Mon, 4 Sep 2023 11:55:37 -0600 Subject: [PATCH] Patch #1480: call get_POST_body once The JWT validation update in PR 1480 contained a small error: by calling the function get_POST_body() twice, the content of the request was unavailable in the second call. This calls only once, but has the downside of requiring a specific set of keys in the json request data. Hence this might be fixed to be more flexible later, see comments in the PR. --- jmclient/jmclient/wallet_rpc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jmclient/jmclient/wallet_rpc.py b/jmclient/jmclient/wallet_rpc.py index 09d41c399..c2ad79068 100644 --- a/jmclient/jmclient/wallet_rpc.py +++ b/jmclient/jmclient/wallet_rpc.py @@ -610,14 +610,14 @@ def _mkerr(err, description=""): try: assert isinstance(request.content, BytesIO) - grant_type = self.get_POST_body(request, ["grant_type",])["grant_type"] + post_body = self.get_POST_body(request, ["grant_type", "refresh_token"]) + grant_type = post_body["grant_type"] if grant_type not in {"refresh_token"}: return _mkerr( "unsupported_grant_type", "The authorization grant type is not supported by the authorization server.", ) - - token = self.get_POST_body(request, [grant_type])[grant_type] + token = post_body["refresh_token"] except: return _mkerr( "invalid_request",