check status code on access token fetch
[shpub.git] / src / shpub / Command / Connect.php
index 68a4e18e354e26c372e69ab789a9e6e499a2f7ab..02f60c7ae6a456a101c8b3cbbef5326596ffbc90 100644 (file)
@@ -98,6 +98,12 @@ class Command_Connect
             )
         );
         $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);