3 declare(strict_types=1);
12 use GuzzleHttp\ClientInterface;
26 private $accessTokenUrl;
33 $this->client = $client;
34 $this->accessTokenUrl = $accessTokenUrl;
35 $this->credentials = $credentials;
43 if (!is_null($this->credentials->getScope())) {
44 $data[
self::SCOPE] = $this->credentials->getScope();
47 'form_params' => $data,
48 'auth' => [$this->credentials->getClientId(), $this->credentials->getClientSecret()]
51 $result = $this->client->request(
"post", $this->accessTokenUrl, $options);
54 $body = json_decode((
string)$result->getBody(),
true);
55 return new TokenModel((
string)$body[self::ACCESS_TOKEN], (
int)$body[self::EXPIRES_IN]);