The answer to this question is: One that is accepted by their people and other governments as the sovereign authority of a nation
To be considered as 'legitimate' in a democratic country, the government must be chosen based on how the people want them to be represented by the candidates. After being chosen, the government officials have the obligation to fulfill all the promises that they ,made during the campaign for the people that supported them