What event gave California temporary independence from Mexico, which later paved the way for the success in the Mexican-American War?

The event that gave California temporary independence from Mexico, which later paved the way for success in the Mexican-American War, was the Bear Flag Revolt. The Bear Flag Revolt occurred in 1846, when a group of American settlers in California rebelled against Mexican rule. They raised the Bear Flag, which had a California grizzly bear and a star on it, and declared the establishment of the California Republic. However, this independence was short-lived as American forces quickly occupied the region and California was later formally ceded to the United States as a result of the Treaty of Guadalupe Hidalgo, which ended the Mexican-American War in 1848.