/** * {@inheritdoc} */ public function getTokenData(SignerInterface $clientCredentialsSigner) { if (!$this->client || !$this->config) { throw new ReauthorizationException('No OAuth reauthorization method was set'); } $request = $this->client->createRequest('POST', null); $request->setBody(Utils::arrayToPostBody($this->config)); $clientCredentialsSigner->sign($request, $this->config['client_id'], $this->config['client_secret']); $response = $this->client->send($request); return new TokenData($response->json()); }
/** * {@inheritdoc} */ public function getTokenData(SignerInterface $clientCredentialsSigner, $refreshToken = null) { if (!$this->client || !$this->config) { throw new ReauthorizationException('No OAuth reauthorization method was set'); } $postBody = ['grant_type' => 'refresh_token', 'refresh_token' => $refreshToken ?: $this->config['refresh_token']]; if ($this->config['scope']) { $postBody['scope'] = $this->config['scope']; } $request = $this->client->createRequest('POST', null); $request->setBody(Utils::arrayToPostBody(new Collection($postBody))); $clientCredentialsSigner->sign($request, $this->config['client_id'], $this->config['client_secret']); $response = $this->client->send($request); return new TokenData($response->json()); }