19 class RestTokenRequest
extends AbstractRestRequest
23 return array(
'grant_type' =>
'client_credentials');
28 return parent::getEndpoint() .
'/oauth2/token';
33 $body = $data ? http_build_query($data,
'',
'&') :
null;
34 $httpResponse = $this->httpClient->request(
38 'Accept' =>
'application/json',
39 'Authorization' =>
'Basic ' . base64_encode(
"{$this->getClientId()}:{$this->getSecret()}"),
44 $body = (string) $httpResponse->getBody()->getContents();
45 $jsonToArrayResponse = !empty($body) ? json_decode($body,
true) : array();
46 return $this->response =
new RestResponse($this, $jsonToArrayResponse, $httpResponse->getStatusCode());