Narrated 'Uqbah bin 'Amir:
I said: 'O Messenger of Allah! We come across a people and they do not host us, and they do not give us our rights, and we do not take anything from them. So the Messenger of Allah (ﷺ) said: 'If they refuse such that you can only take by force, then take.'
[Abu 'Eisa said:] This Hadith is Hasan. It has been reported by Al-Laith bin Sa'd from Yazid bin Abi Habib as well.
This Hadith only means that they would go out for battles and they would pass a people among whom they would not find any food to buy for a price. So the Prophet (ﷺ) told them: If they refuse to sell you, such that you have to take it forcefully, then take it. This is how the explanation has been related in some of the Ahadith. And it has been related that 'Umar bin Al-Khattab, may Allah be please with him, would order similarly.