Improve 401 json exception

Returns an object with ``code`` and ``message`` fields instead of a string.