Skip to content

Commit

Permalink
Fix an error when making a request with a query string, and refreshin…
Browse files Browse the repository at this point in the history
…g an expired token in the same request.
  • Loading branch information
engram-design committed Sep 26, 2024
1 parent cd92e14 commit 140c9d2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/base/ProviderTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 140c9d2

Please sign in to comment.