3 declare(strict_types=1);
30 private $accessTokenUrl;
35 private $tokenStorage;
39 string $accessTokenUrl,
43 $this->accessTokenUrl = $accessTokenUrl;
44 $this->client = $client;
45 $this->credentials = $credentials;
46 $this->tokenStorage = $tokenStorage;
53 'username' => $userName,
54 'password' => $password,
57 'form_params' => $data,
58 'auth' => [$this->credentials->getClientId(), $this->credentials->getClientSecret()],
61 $result = $this->client->post($this->accessTokenUrl, $options);
64 $body = json_decode((
string) $result->getBody(),
true);
66 (
string) $body[self::ACCESS_TOKEN],
67 (
int) $body[self::EXPIRES_IN],
68 (
string) $body[self::REFRESH_TOKEN]
71 $this->tokenStorage->setAccessToken($token->getValue());
72 $this->tokenStorage->setRefreshToken($token->getRefreshToken());