From 140c9d24fef461ef688fb09b520acae6dbc140a2 Mon Sep 17 00:00:00 2001 From: Josh Crawford Date: Thu, 26 Sep 2024 10:52:14 +1000 Subject: [PATCH] Fix an error when making a request with a query string, and refreshing an expired token in the same request. --- src/base/ProviderTrait.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/base/ProviderTrait.php b/src/base/ProviderTrait.php index 25adb8a..56c4952 100644 --- a/src/base/ProviderTrait.php +++ b/src/base/ProviderTrait.php @@ -109,6 +109,10 @@ public function refreshToken(Token $token, bool $force = false): ?Token public function getApiRequest(string $method = 'GET', string $uri = '', ?Token $token, array $options = [], bool $forceRefresh = true): mixed { + // Retain original variables for the retry request, as it can be modified + $originalToken = $token; + $originalOptions = $options; + try { // Normalise the URL and query params $baseUri = ArrayHelper::remove($options, 'base_uri', $this->getResolvedBaseApiUrl($token)); @@ -173,7 +177,7 @@ public function getApiRequest(string $method = 'GET', string $uri = '', ?Token $ $this->refreshToken($token, true); // Then try again, with the new access token - return $this->getApiRequest($method, $uri, $token, $options, false); + return $this->getApiRequest($method, $uri, $token, $originalOptions, false); } // Otherwise, throw the error as normal to allow plugins upstream to handle it