In Spain the government of King Joseph was French; however, it was widely regarded as not lawful, certainly by the Spanish, and obviously by the British, since they fought against it. The Spanish formed an alternative government - the Juntas. And the Spanish monarch was still in existence. This is no doubt why the Portuguese court fled to Brazil; they formed a government in exile, so no-one could say that there was a vacuum in government or that the French could be the authority.
Cheers
C