{"action":"opened","issue":{"url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/110","repository_url":"https://api.github.com/repos/holidayextras/jsonapi-server","labels_url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/110/labels{/name}","comments_url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/110/comments","events_url":"https://api.github.com/repos/holidayextras/jsonapi-server/issues/110/events","html_url":"https://github.com/holidayextras/jsonapi-server/issues/110","id":147181491,"number":110,"title":"Question: best way to implement verbose errors on custom authenticate handler","user":{"login":"paul42","id":278262,"avatar_url":"https://avatars.githubusercontent.com/u/278262?v=3","gravatar_id":"","url":"https://api.github.com/users/paul42","html_url":"https://github.com/paul42","followers_url":"https://api.github.com/users/paul42/followers","following_url":"https://api.github.com/users/paul42/following{/other_user}","gists_url":"https://api.github.com/users/paul42/gists{/gist_id}","starred_url":"https://api.github.com/users/paul42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paul42/subscriptions","organizations_url":"https://api.github.com/users/paul42/orgs","repos_url":"https://api.github.com/users/paul42/repos","events_url":"https://api.github.com/users/paul42/events{/privacy}","received_events_url":"https://api.github.com/users/paul42/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-10T01:18:02Z","updated_at":"2016-04-10T01:18:02Z","closed_at":null,"body":"So, I was wondering how I can create errors in the same manner as the built-in way - \r\nfor example, when I try to POST to a route and don't pass validation, i get a response like this:\r\n\r\n    {\r\n      \"jsonapi\": {\r\n        \"version\": \"1.0\"\r\n      },\r\n      \"meta\": {\r\n        \"copyright\": \"Blah\"\r\n      },\r\n      \"links\": {\r\n        \"self\": \"http://localhost:16006/rest/comments/\"\r\n      },\r\n      \"errors\": [\r\n        {\r\n          \"status\": \"403\",\r\n          \"code\": \"EFORBIDDEN\",\r\n          \"title\": \"Param validation failed\",\r\n          \"detail\": {\r\n            \"name\": \"ValidationError\",\r\n            \"details\": [\r\n              {\r\n                \"message\": \"\\\"title\\\" must be a string\",\r\n                \"path\": \"title\",\r\n                \"type\": \"string.base\",\r\n                \"context\": {\r\n                  \"value\": 2,\r\n                  \"key\": \"title\"\r\n                }\r\n              }\r\n            ],\r\n            \"_object\": {\r\n              \"id\": \"cfdccd45-6395-4b44-b540-41b45b4f3746\",\r\n              \"type\": \"comments\",\r\n              \"title\": 2,\r\n              \"body\": \"whatever!!!?\"\r\n            }\r\n          }\r\n        }\r\n      ]\r\n    }\r\n\r\nbut when I try to make my custom authenticate route respond like thus:\r\n        var currentClientSecret = process.env.CB_CLIENT_SECRET;\r\n    jsonApi.authenticate(function(request, callback) {\r\n      // console.log(request.headers.authorization);\r\n      var authorization = _.get(request, 'headers.authorization', '');\r\n      var isBearerToken = authorization.indexOf('Bearer ') > -1;\r\n      if(isBearerToken){\r\n        var token = authorization.slice(7);\r\n        console.log(token);\r\n    \r\n        try {\r\n          var decoded = jwt.verify(token, new Buffer(currentClientSecret, 'base64'));\r\n          console.log(decoded);\r\n          callback();\r\n        } catch (e) {\r\n          console.log(e);\r\n          callback(e);\r\n        }\r\n      } else {\r\n        var badFormat = new Error('')\r\n        var otherData = {\r\n          status: 401,\r\n          code: 'ENOAUTH',\r\n          title:'Authorization header not in correct format. should be \\'Bearer {{token}}\\''\r\n        }\r\n        _.assign(badFormat, otherData);\r\n        callback(badFormat);\r\n      }\r\n    \r\n    });\r\n\r\nso when I try to test it by submitting a request without the authorization header, I don't get back a verbose response, I get back just a blank 401, no body. is there a way to tap into the nice pattern from above? or should I be implementing authentication differently? "}}