Junada bin Abu Umaya reported,

Among the terms he bound us to was that we pledge allegiance to hear and obey, in what we like and what we dislike, in hardship and in ease, and even when others are given preference over us, and that we not contest authority with those who hold it, unless you see open disbelief regarding which you have clear proof from Allah.

Bukhari 7056

Sahih

فقال فيما أخذ علينا أن بايعنا على السمع والطاعة في منشطنا ومكرهنا وعسرنا ويسرنا وأثرة علينا وأن لا ننازع الأمر أهله إلا أن تروا كفرا بواحا عندكم من الله فيه برهان

البخاري 7056صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Tribulations
Chapter
Saying of the Prophet ﷺ, "You will see after me matters you disapprove of"
Numbering
Darussalam 7056
Bukhari 7056