The Messenger of Allah ﷺ said in a lengthy hadith, "O Allah, I ask You for the doing of good deeds, the abandonment of evil deeds, and love for the poor. I ask that You forgive me and have mercy on me. When You will a trial upon a people, take me to You without being subjected to that trial. I ask You for Your love, the love of those who love You, and the love of every deed that brings me closer to Your love."
قال رسول الله ﷺ في حديث طويل: اللهم! إني أسألك فعل الخيرات، وترك المنكرات، وحب المساكين، وأن تغفر لي، وترحمني، وإذا أردت فتنة قوم فتوفني غير مفتون، أسألك حبك وحب من يحبك، وحب عمل يقرب إلى حبك.
Tirmidhi (3235) narrated it, and this is his wording, as did Ahmad (22109) and Ibn Khuzayma in his book on Tawheed (441), all of them through Yahya bin Abu Kathir, from Zayd bin Salam, from Abu Salam, from Abdul-Rahman bin Aaish Hadrami, who reported that he was told by Malik bin Yakhamir Saksaki, from Muaz bin Jabal, and he related it.Its chain of transmission is hasan, and the discussion of it is set out in detail in the book on faith.