Send HTTP 401 on invalid token
[grauphel.git] / lib / oauth.php
index 6900c20305e0fba6ca68d8bd79886c91d0b6cfc6..5f84e7e319c62b87be689239cda8e5f51088a814 100644 (file)
@@ -103,7 +103,14 @@ class OAuth
             return OAUTH_PARAMETER_ABSENT;
         }
 
-        $token = $this->tokens->load('access', $provider->token);
+        try {
+            $token = $this->tokens->load('access', $provider->token);
+        } catch (OAuthException $e) {
+            if ($e->getCode() == OAUTH_TOKEN_REJECTED) {
+                return OAUTH_TOKEN_REJECTED;
+            }
+            throw $e;
+        }
         $provider->token_secret = $token->secret;
         return OAUTH_OK;
     }