Changed to set response code to 401 on failed authentication.