We were with the Messenger of Allah ﷺ on a journey when the sky became overcast and the direction of the qiblah became unclear to us. So we prayed and marked the direction we faced. When the sun rose, we realized that we had prayed toward something other than the qiblah. We mentioned this to the Prophet ﷺ, and Allah revealed, "So wherever you turn, there is the Face of Allah" [Baqarah 2:115].
حدثنا يحيى بن حكيم حدثنا أبو داود حدثنا أشعث بن سعيد أبو الربيع السمان عن عاصم بن عبيد الله
كنا مع رسول الله ﷺ في سفر فتغيمت السماء وأشكلت علينا القبلة فصلينا وأعلمنا فلما طلعت الشمس إذا نحن قد صلينا لغير القبلة فذكرنا ذلك للنبي ﷺ فأنزل الله {فأينما تولوا فثم وجه الله}
No references are available.
[Its chain of transmission is daif] Tirmidhi reported it in Salah, chapter on a man who prays facing other than the qibla in cloudy weather, no. 345, from the hadith of Ashath bin Saeed Samman, with this wording. He said, "This hadith's chain is not that strong." Ashath was followed by Amr bin Qays as reported by Tayalisi, no. 1145, but Asim is daif, as mentioned before, no. 907. There is also a daif corroborating narration in Bayhaqi and elsewhere.