All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
It is highly unlikely that a person believes that sunrise, sunset, and the multitude of creation have a right on Allah, the Almighty, or a standing with Him, so as to seek intercession by them with Allah or ask or swear by them before Allah; so we imagine that you said these words by mistake and that you did not really mean them; or as you said, ‘it just sort of came out of your mouth’.
This is in terms of meaning; in terms of wording, however, then such expressions are not permissible to be said while supplicating because they are considered either as beseeching Allah by some of His creation, or as seeking their intercession with Allah, while Allah did not make them a means of intercession, so both of them are not permissible.
Imaam Abu Haneefah said, “No one should supplicate Allah except with Allah, and I dislike (that someone says), ‘by so-and-so’, or, ‘by Your Prophets and Messengers’, or, ‘by the House (the Ka’bah) and Al-Mash’ar Al-Haraam (in Muzdalifah)’.”
Shaykh Ibn Taymiyyah said, “Asking Allah by His creation is not permissible; because the creation has no right on the Creator, so it is not permissible to ask with something that is not worthy (to be asked with).”
Ibn Abi Al-’Izz, from the Hanafi School of jurisprudence, mentioned two prohibitions regarding this in Sharh At-Tahhaawiyyah:
1- That he swore by other than Allah,
2- That he believes that someone has a right on Allah. Indeed, it is not permissible to swear by other than Allah, and no one has a right on Allah except what He has made a right on Himself.”
In any case, such a wording does not lead to major Shirk, but it is a Shirk pertaining to words or minor Shirk. So you should seek the forgiveness of Allah and say ‘La Ilaaha illa Allah’ (None has the right to be worshipped but Allah). It is enough for you to do so.
The Prophet said, “Whoever swore and said, ‘By Al-Laat and Al-Uzza (pagan idols),’ let him say, ‘La Ilaaha illa Allah.’” [Al-Bukhari]
Ibn Hajar said, “Ibn Al-Arabi said, ‘Whoever swears by them (Al-Laat and Al-Uzza) out of ignorance or because of being distracted should say, ‘La Ilaaha illa Allah’; then Allah will expiate his sin and bring his heart back from forgetfulness to heedfulness (remembrance) and his tongue to the truth and repel the idle talk that he spoke from him.”
Allah knows best.