protected function verifyIfTokenNeedsRefreshing(ResponseInterface $response, $action, $vars = [])
 {
     if ($response->getStatusCode() != 401) {
         return $response;
     }
     if ($this->tokenChecked) {
         throw new Exception(sprintf('Response could not be obtained due to invalid token and response. Please check your credentials and action: %s', $response->getEffectiveUrl()));
     }
     $this->tokenChecked = true;
     if (file_exists($this->tokenLocation())) {
         unlink($this->tokenLocation());
     }
     return $this->get($action, $vars);
 }
Esempio n. 2
0
 /**
  * Check if request was successful
  * @param \GuzzleHttp\Message\ResponseInterface $response
  * @throws \UnexpectedValueException
  */
 protected function validateResponse($response)
 {
     if ($response->getStatusCode() !== 200) {
         throw new \UnexpectedValueException('Failed to download ' . $response->getEffectiveUrl() . '. Server responded with ' . $response->getStatusCode() . ' instead of 200.');
     }
 }
Esempio n. 3
0
 /**
  * Get the effective URL that resulted in this response (e.g. the last
  * redirect URL).
  *
  * @return string
  */
 public function effectiveUrl()
 {
     return $this->response->getEffectiveUrl();
 }