As for Sayar, he reported it from the Prophet ﷺ. As for Yahya, he reported it from his father, from his grandfather, who said, "We pledged allegiance to the Messenger of Allah ﷺ to listen and obey in hardship and in ease, in matters we found pleasing and in those we disliked, even when others were given preference over us, that we would not contest authority with those who held it, that we would stand for the truth wherever we were, and that we would not fear, in matters concerning Allah, the blame of any blamer."
حدثنا محمد بن جعفر حدثنا شعبة عن سيار ويحيى بن سعيد القاضي أنهما سمعا
أما سيار فقال عن النبي ﷺ وأما يحيى فقال عن أبيه عن جده قال بايعنا رسول الله ﷺ على السمع والطاعة في عسرنا ويسرنا ومنشطنا ومكرهنا والأثرة علينا وأن لا ننازع الأمر أهله ونقوم بالحق حيث كان ولا نخاف في الله لومة لائم
Its chain of transmission is sahih, and the version transmitted through Yahya bin Saeed is more sahih. Sayyar is Ibn Abu Sayyar, Abu Hakam Anazi Wasiti, of whom Ahmad said, "Reliable, firmly established, truthful among all the sheikhs." Yahya bin Saeed the judge is Ansari, the well-known hadith master, who served as judge over Madinah, then over Hashimiyyah, then in Baghdad. Ubada bin Walid bin Ubada was deemed reliable by everyone, and they praised him, and his narration appears in the Sahihayn.The hadith is found in Nasai, 7/139, number 4154, in the chapter on the pledge of allegiance, "The Pledge of Allegiance Concerning Self-Preference." And in Ibn Majah, in the book of jihad, "The Pledge of Allegiance," 2/957, number 2866.