Send HTTP 401 on invalid token
[grauphel.git] / lib / tokenstorage.php
index f8f0806f95b89d61f9f092c483852af42fb674ce..4b5f42094978a139c156a41aff6b8f3e1c47d5ac 100644 (file)
@@ -95,12 +95,15 @@ class TokenStorage
         )->fetchRow();
 
         if ($tokenRow === false) {
-            throw new OAuthException('Unknown token: ' . $type . ' / ' . $tokenKey);
+            throw new OAuthException(
+                'Unknown token: ' . $type . ' / ' . $tokenKey,
+                OAUTH_TOKEN_REJECTED
+            );
         }
 
         $token = $this->fromDb($tokenRow);
         if ($token->tokenKey != $tokenKey) {
-            throw new OAuthException('Invalid token');
+            throw new OAuthException('Invalid token', OAUTH_TOKEN_REJECTED);
         }
 
         return $token;