“Under the Mexican constitution, the US had no right to take it.”
Except the US didn’t “take” California. Mexico ceded their northern territories to the US in the treaty of Guadalupe - Hidalgo which ended the Mexican - American war -which was started by Mexico.
California declared its independence from Mexico, and then the US grabbed California.