diff --git a/app/controllers/api/oauth.php b/app/controllers/api/oauth.php
index dce5084ec3320a528093e2f9fe2c02f6e627bff5..22caab1bc7fbcbb19544c3acae6004069ebdbf88 100644
--- a/app/controllers/api/oauth.php
+++ b/app/controllers/api/oauth.php
@@ -66,6 +66,12 @@ class Api_OauthController extends StudipController
 
         try {
             $consumer = RESTAPI\Consumer\Base::detectConsumer('oauth', 'request');
+            if (!$consumer) {
+                $this->response->set_status(400, 'No consumer detected');
+                $this->render_nothing();
+                return;
+            }
+
             if (Request::submitted('allow')) {
                 $result = $consumer->grantAccess($GLOBALS['user']->id);