diff --git a/src/BaseClient.php b/src/BaseClient.php index d232858..1f4be7b 100644 --- a/src/BaseClient.php +++ b/src/BaseClient.php @@ -272,9 +272,10 @@ protected function requestToken(string $clientId, string $clientSecret, TokenReq $response = $this->rawRequest('POST', static::API_TOKEN_URI, [ 'headers' => [ 'Accept' => 'application/json', - 'Authorization' => sprintf('Basic %s', $credentials) + 'Authorization' => sprintf('Basic %s', $credentials), + 'Content-Type' => 'application/x-www-form-urlencoded', ], - 'query' => $token->toArray() + 'body' => http_build_query($token->toArray()) ]); $responseTypes = [ diff --git a/tests/BaseClientTest.php b/tests/BaseClientTest.php index d97327c..c13f86f 100644 --- a/tests/BaseClientTest.php +++ b/tests/BaseClientTest.php @@ -232,11 +232,10 @@ protected function authenticateByClientCredentials(?ResponseInterface $response $httpClientMock->method('request')->with('POST', 'https://login.bol.com/token', [ 'headers' => [ 'Accept' => 'application/json', - 'Authorization' => 'Basic ' . $credentials + 'Authorization' => 'Basic ' . $credentials, + 'Content-Type' => 'application/x-www-form-urlencoded' ], - 'query' => [ - 'grant_type' => 'client_credentials' - ] + 'body' => 'grant_type=client_credentials' ])->willReturn($response); // use the HttpClient mock created in this method for authentication, put the original one back afterwards @@ -373,13 +372,10 @@ protected function authenticateByAuthorizationCode(?ResponseInterface $response $httpClientMock->method('request')->with('POST', 'https://login.bol.com/token', [ 'headers' => [ 'Accept' => 'application/json', - 'Authorization' => 'Basic ' . $credentials + 'Authorization' => 'Basic ' . $credentials, + 'Content-Type' => 'application/x-www-form-urlencoded' ], - 'query' => [ - 'grant_type' => 'authorization_code', - 'code' => '123456', - 'redirect_uri' => 'http://someserver.xxx/redirect', - ] + 'body' => 'grant_type=authorization_code&code=123456&redirect_uri=http%3A%2F%2Fsomeserver.xxx%2Fredirect' ])->willReturn($response); // use the HttpClient mock created in this method for authentication, put the original one back afterwards @@ -428,12 +424,10 @@ protected function authenticateByRefreshToken(?ResponseInterface $response = nul $httpClientMock->method('request')->with('POST', 'https://login.bol.com/token', [ 'headers' => [ 'Accept' => 'application/json', - 'Authorization' => 'Basic ' . $credentials + 'Authorization' => 'Basic ' . $credentials, + 'Content-Type' => 'application/x-www-form-urlencoded' ], - 'query' => [ - 'grant_type' => 'refresh_token', - 'refresh_token' => $this->validRefreshToken->getToken() - ] + 'body' => 'grant_type=refresh_token&refresh_token=' . $this->validRefreshToken->getToken() ])->willReturn($response); // use the HttpClient mock created in this method for authentication, put the original one back afterwards diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 96a73b2..4a49d53 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -41,11 +41,10 @@ protected function authenticateByClientCredentials() $httpClientMock->method('request')->with('POST', 'https://login.bol.com/token', [ 'headers' => [ 'Accept' => 'application/json', - 'Authorization' => 'Basic ' . $credentials + 'Authorization' => 'Basic ' . $credentials, + 'Content-Type' => 'application/x-www-form-urlencoded' ], - 'query' => [ - 'grant_type' => 'client_credentials' - ] + 'body' => 'grant_type=client_credentials' ])->willReturn($response); // use the HttpClient mock created in this method for authentication, put the original one back afterwards