supabase icon indicating copy to clipboard operation
supabase copied to clipboard

onAuthStateChange only fires "INITIAL_SESSION" event?

Open tedik123 opened this issue 1 year ago • 2 comments

Hello I'm not sure what I'm doing wrong because this setup worked on another project a bit ago but onAuthStateChange does not fire besides the initial session event. I believe I am successfully logging in with google OAuth because it does redirect me back to localhost and if I read the session data I have my tokens and basic google account info. Sign in only fires if I am signed in and then I switch tabs and back to it, but not when I actually log in. This is all inside a userStore using pinia and the userStore is always on the page. Any idea what I'm doing wrong?

const supabase = useSupabaseClient()
// use google oAuth
async function handleLogin() {
       await supabase.auth.signInWithOAuth({
                provider: 'google',
       })
}

supabase.auth.onAuthStateChange(async (event, session) => {
        console.log('event', event)
        switch (event) {
            case "INITIAL_SESSION":
                console.log("Initial session", session)
                break
            case 'SIGNED_IN':
                console.log('User signed in');
                await handleSignInEvent()
                break;
            
        }
 });

tedik123 avatar Feb 04 '24 18:02 tedik123

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar May 06 '25 13:05 github-actions[bot]

same problem here. Did you find any fix for the issue? It is me or is Supabase becoming very unstable lately?

tarekxsellami avatar Jun 18 '25 10:06 tarekxsellami