Were the Umayyads and Abbasids both Shia?
The Umayyad and Abbasid both oppressed the Shia at different points in time. The Umayyad gained power after Ali was unable to take his place as the leader of the believers because of his age. In his place, Abu Bakr, the Prophet’s father-in-law, took over leadership. After the death of Abu Bakr, Umar ibn Al-Khattab took over as the second caliph of the Rashidun Empire and he was later succeeded by Uthman ibn Affan. Uthman was assassinated and Ali finally took over leadership. However, because of conflict with the other Muslims who were supported by the Umayyad, Ali was assassinated and his position taken by the then governor of Syria who was from the Umayyad family. The Umayyad attempted to pursue a hereditary dynasty but the Abbasid, another strong family with the support of the Shia, opposed, and the Umayyad leadership ceased. After the Abbasid gained power they turned against the Shia because of their contrasting beliefs and began persecuting them.
In summary, the Umayyad and Abbasid belong to the Sunni group which believes leadership is vested on the person supported by the majority because Allah has allowed it. The Shia, on the other hand, believe that leadership is vested on one chosen by Allah through his Messenger as was the case for Ali in the Hadith of the pond of Ghadir Khumm. In context, it is the interpretation of this Hadith that resulted in the split and misunderstanding between Sunnis and Shias.
Actually, neither of these dynasties was Shia. Both the Umayyads and the Abbasids were Sunni.
The Sunni and the Shia split early in Islamic history. They split mainly over who should be the successor to the Prophet Muhammad. The Shia believed that successors should come from the Prophet's family while Sunni believed that the leader should be anyone who was best qualified.
The Umayyad Dynasty emerged out of a Muslim civil war. In that conflict, the leaders of the Umayyads fought against Ali, who was Muhammad's cousin and son-in-law. Ali was the one that Shi'ites believed should be the leader of all Muslims. Since they were fighting against Ali, clearly they were not Shia. The Abbasids did have Shia help in fighting against the Umayyads, but they did not adhere to Shia beliefs and, once they were in power, they came into conflict with the Shia.
So, both dynasties were in fact Sunni.