diff --git a/lib/cartodb/api/auth_api.js b/lib/cartodb/api/auth_api.js index 0f31e721..fc490585 100644 --- a/lib/cartodb/api/auth_api.js +++ b/lib/cartodb/api/auth_api.js @@ -73,7 +73,12 @@ AuthApi.prototype.authorizedByAPIKey = function(user, req, callback) { return callback(err); } if ( !isValidApiKey(apikey)) { - return callback(null, false); + const error = new Error('Unauthorized'); + error.type = 'auth'; + error.subtype = 'api-key-not-found'; + error.http_status = 401; + + return callback(error); } return callback(null, true);