According to the Immigration, Refugees and Citizenship Canada (IRCC), for the purpose of sponsoring their foreign spouse, a Canadian permanent resident or citizen cannot sponsor their same-sex spouse unless the marriage is recognized by the relevant Canadian provincial or territorial authority where they live.
Therefore, the foreign spouse will need to apply for a spousal sponsorship, provide evidence of the valid same-sex marriage, and meet other eligibility requirements to obtain legal residency in Canada.
It's important to note that Canadian immigration laws and regulations are subject to change, so it's always best to consult the latest information and guidelines provided by the IRCC.