You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React Native with Expo, currently running on the web
Detailed Problem Description
My app is built using React Native Expo framework, currently running on the web. I am implementing Google sign-in using Firebase Authentication with signInWithRedirect(). After a successful sign-in, getRedirectResult() keeps returning null instead of the expected result, even though the user is authenticated and signed in successfully.
I am currently using Option 1 as I am hosting the app on firebase, and having a custom domain.
This is what I have already done:
I m using a custom domain and I've set the firebase config authDomain to my custom domain
I've added the custom domain in the Authorized redirect URIs in GCP console
I've also added my custom domain as a authorized domain in firebase console
I've also allowed for all third party cookies.
Why is this still happening? I tried various suggestions on Stack Overflow and GitHub issues but none worked. I suspect that because signInWithRedirect forces a full page reload, the result returns as null.
Please help! Thank you
Steps and code to reproduce issue
2 ways of writing the code that I tried:
Method 1
const handleGoogleSignIn = async () => {
const provider = new GoogleAuthProvider();
try {
await signInWithRedirect(auth, provider)
} catch (error) {
console.error(error);
}
}
// This function handles the result after the user is redirected back
const handleRedirectSignIn = async () => {
try {
const result = await getRedirectResult(auth);
alert(result) //this returns null
if (result && result.user) {
alert(`Welcome!`);
router.push('/HomeScreen');
} else {
alert('User not authenticated.');
}
} catch (error) {
console.error("Error during redirect sign-in:", error);
alert('Failed to sign in with Google.');
}
};
useEffect(() => {
handleRedirectSignIn();
}, []);
Method 2:
const provider = new GoogleAuthProvider();
try {
await signInWithRedirect(auth, provider)
const result = await getRedirectResult(auth);
if (result) {
alert('Sign-in successful!');
router.push('/HomeScreen');
} else {
alert('Failed to sign in with Google.');
}
The text was updated successfully, but these errors were encountered:
Operating System
macOS
Environment (if applicable)
React Native
Firebase SDK Version
11.0.2
Firebase SDK Product(s)
Auth
Project Tooling
React Native with Expo, currently running on the web
Detailed Problem Description
My app is built using React Native Expo framework, currently running on the web. I am implementing Google sign-in using Firebase Authentication with
signInWithRedirect()
. After a successful sign-in,getRedirectResult()
keeps returningnull
instead of the expected result, even though the user is authenticated and signed in successfully.I followed the best practices here: https://firebase.google.com/docs/auth/web/redirect-best-practices
I am currently using Option 1 as I am hosting the app on firebase, and having a custom domain.
This is what I have already done:
authDomain
to my custom domainWhy is this still happening? I tried various suggestions on Stack Overflow and GitHub issues but none worked. I suspect that because
signInWithRedirect
forces a full page reload, the result returns asnull
.Please help! Thank you
Steps and code to reproduce issue
2 ways of writing the code that I tried:
Method 1
Method 2:
The text was updated successfully, but these errors were encountered: