diff --git a/CHANGELOG.md b/CHANGELOG.md index e05dfe1..841309d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All Notable changes to `ViMbAdminClient` will be documented in this file. Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. +## 1.1.3 (released 2021-01-11) + +### Fixed +- Remove defaults from config +- Separate Guzzle Client for oauth + ## 1.1.2 (released 2020-03-06) ### Fixed diff --git a/src/ViMbAdminClient.php b/src/ViMbAdminClient.php index a97e9dc..e713131 100644 --- a/src/ViMbAdminClient.php +++ b/src/ViMbAdminClient.php @@ -108,12 +108,9 @@ public function setupClient( string $clientSecret, $tokenUri = '/oauth/token') { - $handlerStack = HandlerStack::create(); - $client = new Client( + $oauthClient = new Client( [ - 'handler'=> $handlerStack, 'base_uri' => $apiUrl, - 'auth' => 'oauth2', 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', @@ -128,8 +125,8 @@ public function setupClient( ClientCredentials::CONFIG_TOKEN_URL => $tokenUri, ]; - $grant = new ClientCredentials($client, $config); - $middleware = new ViMbAdminOAuthMiddleware($client, $grant, null, $this->tokenStore); + $grant = new ClientCredentials($oauthClient, $config); + $middleware = new ViMbAdminOAuthMiddleware($oauthClient, $grant, null, $this->tokenStore); // see if we have a token already and load it. $key = $this->tokenStore->serializeKey($grant); @@ -143,10 +140,22 @@ public function setupClient( $middleware->setAccessToken($accessToken); } + $handlerStack = HandlerStack::create(); $handlerStack->push($middleware->onBefore()); $handlerStack->push($middleware->onFailure(5)); - $this->client = $client; + $this->client = new Client( + [ + 'handler'=> $handlerStack, + 'base_uri' => $apiUrl, + 'auth' => 'oauth2', + 'headers' => [ + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', + ], + 'exceptions' => false, + ] + ); $this->isInitialised = true; return $this;