check status code on access token fetch
authorChristian Weiske <cweiske@cweiske.de>
Wed, 7 Sep 2016 20:50:08 +0000 (22:50 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 7 Sep 2016 20:50:08 +0000 (22:50 +0200)
src/shpub/Command/Connect.php

index 68a4e18..02f60c7 100644 (file)
@@ -98,6 +98,12 @@ class Command_Connect
             )
         );
         $res = $req->send();
             )
         );
         $res = $req->send();
+        if (intval($res->getStatus() / 100) !== 2) {
+            Log::err('Failed to fetch access token');
+            Log::err('Server responded with HTTP status code ' . $res->getStatus());
+            Log::err($res->getBody());
+            exit(2);
+        }
         if ($res->getHeader('content-type') != 'application/x-www-form-urlencoded') {
             Log::err('Wrong content type in auth verification response');
             exit(2);
         if ($res->getHeader('content-type') != 'application/x-www-form-urlencoded') {
             Log::err('Wrong content type in auth verification response');
             exit(2);