/** * @inheritdoc */ public function refreshToken() { if (!$this->client->getToken()) { throw new \Exception('Token is not set'); } $response = $this->httpClient->post(AuthorizationModel::ENDPOINT_BASE . AuthorizationModel::ENDPOINT_TOKEN, ['refresh_token' => $this->client->getToken()->getRefreshToken(), 'client_id' => $this->client->getClientId(), 'client_secret' => $this->client->getClientSecret(), 'grant_type' => AuthorizationModel::GRANT_REFRESH]); return $this->tokenMapper->buildToken($response->getBody()); }
/** * Prepare Authentication headers required by Imgur and/or Mashape * * @return array */ protected function prepareAuthenticationHeaders() { $headers = []; $headers['Authorization'] = 'Client-ID ' . $this->client->getClientId(); if ($this->client->getToken() && $this->client->getToken()->getAccessToken()) { $headers['Authorization'] = 'Bearer ' . $this->client->getToken()->getAccessToken(); } if ($this->client->getMashapeKey()) { $headers['X-Mashape-Key'] = $this->client->getMashapeKey(); } return $headers; }