Can you use `abort(401)` and create a custom error handler like this https://stackoverflow.com/a/8316995? We recently switched to using Flask's abort() elsewhere in this file as it makes it easier to refactor.