Signin With Redirect not working
Opened this issue · 5 comments
Reproduction
https://github.com/posva/nuxt--vuefire-example-spark-plan
Steps to reproduce the bug
-
trigger signInWithRedirect(provider) from firebase auth.
-
redirect to the oauth provider (e.g., twitter).
-
sign in successfully.
-
user is redirected back but not logged in.
-
no persistent auth state or missing result from getRedirectResult().
Screenrecorder-2025-04-16-03-29-39-789.mp4
Expected behavior
after returning from the oauth provider, calling getRedirectResult() should yield the current user state and the auth state should persist across reloads.
Actual behavior
the app reloads and useCurrentUser() returns null
getRedirectResult() doesn't resolve the user
persistence appears broken, even when set to local
Additional information
signInWithPopup() works fine
It's happening to me
Same for me
Same issue. signInWithPopup works but signInWithRedirect doesn't:
<script setup lang="ts">
import { getRedirectResult, signInWithRedirect, GoogleAuthProvider } from 'firebase/auth'
import { useFirebaseAuth } from 'vuefire'
const auth = useFirebaseAuth()
function signInWithGoogle() {
signInWithRedirect(auth, new GoogleAuthProvider())
}
</script>@Johnnyevans32 , this fixes the issue for me: https://stackoverflow.com/questions/77270210/firebase-onauthstatechanged-user-returns-null-when-on-localhost
This is more of a firebase issue, not a vuefire issue. I've been experiencing this for years in development. What I do is something like this in my imports, then toggle the comment when I need to login to test.
import {
GoogleAuthProvider,
// signInWithPopup, // use this with localhost, still might need to refresh or manually update address bar
signInWithRedirect,
} from "firebase/auth";