/**
  * Check if the response failed and if the token is expired.
  * 
  * Any errors returned from the API server will be thrown as an Exception.
  * 
  * @param  array $response 
  * @return boolean
  */
 private function checkResponse()
 {
     $response = $this->request->getResponse();
     $httpCode = $this->request->getResponseCode();
     if (!$response) {
         throw new \Exception('Requesting Access Token failed');
         return false;
     }
     if ($httpCode == 400 && isset($response['error'])) {
         // throw an Exception with the returned error message
         $msg = isset($response['error_description']) ? $response['error_description'] : $response['error'];
         throw new \Exception($msg);
         return false;
     }
     return true;
 }