change NotAuthorizedError to UnauthorizedError