From ac2ae136907d03935f7e948b59fb23dbc6fb8b8b Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Tue, 9 Jun 2020 21:26:31 -0400 Subject: [PATCH] Better handling for ecobee authorization errors --- api/ecobee.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/ecobee.php b/api/ecobee.php index 70590bd..53fcb87 100644 --- a/api/ecobee.php +++ b/api/ecobee.php @@ -250,6 +250,14 @@ class ecobee extends external_api { } throw new Exception($response['status']['message']); } + else if (isset($response['error']) === true) { + // Authorization errors are a bit different + // https://www.ecobee.com/home/developer/api/documentation/v1/auth/auth-req-resp.shtml + if($this::$log_mysql !== 'all') { + $this->log_mysql($curl_response, true); + } + throw new Exception(isset($response['error_description']) === true ? $response['error_description'] : $response['error']); + } else { return $response; }