From cf419a5556bf7b5f49990eb2fd5218150efd8cac Mon Sep 17 00:00:00 2001 From: Noa83 Date: Thu, 13 Jan 2022 14:14:21 +0100 Subject: [PATCH] Update OAuth.php - Fix 401 error when sub array for filters or plainPassword in parameters --- lib/Auth/OAuth.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Auth/OAuth.php b/lib/Auth/OAuth.php index 10f1b15a..742cad21 100755 --- a/lib/Auth/OAuth.php +++ b/lib/Auth/OAuth.php @@ -579,7 +579,16 @@ protected function prepareRequest($url, array $headers, array $parameters, $meth } //Add the parameters - $oAuthHeaders = array_merge($oAuthHeaders, $parameters); + $cleanedParameters = $parameters; + $possibleKeys = ['filters' => 'filters', 'plainPassword' => 'plainPassword']; + if (!empty(array_intersect_key($possibleKeys, $cleanedParameters))){ + foreach ($possibleKeys as $possibleKey){ + if (array_key_exists($possibleKey, $cleanedParameters)) { + unset($cleanedParameters[$possibleKey]); + } + } + } + $oAuthHeaders = array_merge($oAuthHeaders, $cleanedParameters); $base_info = $this->buildBaseString($url, $method, $oAuthHeaders); $composite_key = $this->getCompositeKey(); $oAuthHeaders['oauth_signature'] = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));