Handle authentication failures more gracefully