Skip to content

Commit 949926e

Browse files
author
Antoine Aflalo
committed
fix(client): Force client to generate request
Instead of relying on the client of the OAuth provider. When doing that, we don't get the right attribute for the request.
1 parent 4498afa commit 949926e

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/Client/OAuthClient.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use GuzzleHttp\ClientInterface;
1313
use GuzzleHttp\Exception\BadResponseException;
1414
use GuzzleHttp\Exception\RequestException;
15+
use GuzzleHttp\RequestOptions;
1516
use League\OAuth2\Client\Token\AccessToken;
1617
use Psr\Http\Message\ResponseInterface;
1718
use ZEROSPAM\Framework\SDK\Client\Exception\SDKException;
@@ -154,15 +155,17 @@ public function processRequest(IRequest $request): IResponse
154155
{
155156
$request->incrementTries();
156157

157-
$httpRequest = $this->configuration->getProvider()->getAuthenticatedRequest(
158-
$request->requestType()->getValue(),
159-
$request->toUri(),
160-
$this->token,
161-
$request->requestOptions()
162-
);
158+
$headers = $this->configuration->getProvider()->getHeaders($this->token);
159+
160+
$options = $request->requestOptions();
161+
if (isset($options[RequestOptions::HEADERS])) {
162+
$options[RequestOptions::HEADERS] = array_merge($options[RequestOptions::HEADERS], $headers);
163+
} else {
164+
$options[RequestOptions::HEADERS] = $headers;
165+
}
163166

164167
try {
165-
$response = $this->guzzleClient->send($httpRequest);
168+
$response = $this->guzzleClient->request($request->httpType()->getValue(), $request->toUri(), $options);
166169
$parsedData = JSONParsing::responseToJson($response);
167170

168171
if (isset($this->middlewares[$response->getStatusCode()])) {

0 commit comments

Comments
 (0)