Changed response of API when the user is not authenticated to returning a HTTP 401 code rather than a HTTP 301 redirect