Fix unauthorized error handling