3 declare(strict_types=1);
30 private $accessTokenUrl;
35 private $refreshTokenProvider;
40 private $anonymousIdProvider;
44 string $accessTokenUrl,
49 $this->accessTokenUrl = $accessTokenUrl;
50 $this->client = $client;
51 $this->credentials = $credentials;
52 $this->refreshTokenProvider = $refreshTokenProvider;
53 $this->anonymousIdProvider = $anonymousIdProvider;
61 if (!is_null($this->anonymousIdProvider)) {
62 $data[
'anonymous_id'] = $this->anonymousIdProvider->getAnonymousId();
65 'form_params' => $data,
66 'auth' => [$this->credentials->getClientId(), $this->credentials->getClientSecret()],
69 $result = $this->client->post($this->accessTokenUrl, $options);
72 $body = json_decode((
string) $result->getBody(),
true);
75 (
string) $body[self::ACCESS_TOKEN],
76 (
int) $body[self::EXPIRES_IN],
77 (
string) $body[self::REFRESH_TOKEN]
86 return $this->refreshTokenProvider->refreshToken();