Whenever food was brought to the Prophet ﷺ from someone outside his household, he would ask about it. If he was told it was a gift, he would eat from it. If he was told it was charity, he would say, "Eat," but would not eat from it himself.
حدثنا عبد الرحمن حدثنا حماد بن سلمة عن محمد بن زياد قال سمعت
كان النبي ﷺ إذا أتي بطعام من غير أهله سأل عنه فإن قيل هدية أكل وإن قيل صدقة قال كلوا ولم يأكل
Its isnad is sahih, and it is in Jami al-Masanid 7:338, from this same place, and it will also come again at 8036, 8446, 9253, 10381. Bukhari related it, 5:149, and Muslim, 1:297, both through the route of Muhammad bin Ziyad. See also 7744.