From 4e388eac0a92ac683182677d8c0a6b45e9b4a3e8 Mon Sep 17 00:00:00 2001
From: Arunmozhi <arunmozhi@opencraft.com>
Date: Mon, 16 May 2022 13:13:14 +1000
Subject: [PATCH] refactor: replace oauth param fetching from client to
 signature method

The OAuthlib 1.0 Client's get_oauth_params fails when processing Webob
request object with the body stored as a binary instead of string.
This commit replaces the client function with a different one which
doesn't involve body hashing, as the body hash is calculated explicitly.
---
 lti_consumer/lti_1p1/oauth.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lti_consumer/lti_1p1/oauth.py b/lti_consumer/lti_1p1/oauth.py
index c1a127f..4da150e 100644
--- a/lti_consumer/lti_1p1/oauth.py
+++ b/lti_consumer/lti_1p1/oauth.py
@@ -147,7 +147,7 @@ def log_authorization_header(request, client_key, client_secret):
     oauth_body_hash = str(base64.b64encode(sha1.digest()))
     log.debug("[LTI] oauth_body_hash = %s", oauth_body_hash)
     client = oauth1.Client(client_key, client_secret)
-    params = client.get_oauth_params(request)
+    params = oauth1.rfc5849.signature.collect_parameters(headers=request.headers, exclude_oauth_signature=False)
     params.append(('oauth_body_hash', oauth_body_hash))
     mock_request = SignedRequest(
         uri=str(urllib.parse.unquote(request.url)),
-- 
GitLab