Jareer reported,

I came to the Prophet ﷺ and said to him, "I pledge allegiance to you to listen and obey in what I like and in what I dislike."The Prophet ﷺ said, "Are you able to do that, Jareer? Can you bear that? Say, 'in what I am able to do.'"So he took my pledge of allegiance, including sincere counsel to every Muslim.

Nasai 4179

Sahih

أخبرني محمد بن قدامة عن جرير عن مغيرة عن أبي وائل والشعبي قالا

قال جرير

أتيت النبي ﷺ فقلت له أبايعك على السمع والطاعة فيما أحببت وفيما كرهت قال النبي ﷺ أو تستطيع ذلك يا جرير أو تطيق ذلك قال قل فيما استطعت فبايعني والنصح لكل مسلم

النسائي 4179صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Pledge of allegiance
Chapter
Pledge of allegiance in what one likes and dislikes
Numbering
Darussalam 4179
Nasai 4179