I am working on a Javascript-based website. I integrated Firebase Google and Facebook SignIn. Everything was working fine. After 3 months, when I checked again. Firebase Google and Facebook Sign-in starts failing. I do not understand what happened. I checked everything, firebaseConfig, project_id, and other things. Everything is okay. I cleared the cache and ran it on different browsers, however, it still failed.
One error that I get in the beginning is related with /__/firebase/init.json. “404(not found)”. However, after that my browser shows the Google SignIn page and I signs In. But then in “onAuthStateChanged(auth, async (user) => {” it says, user is not Signed In.
import { getAuth, FacebookAuthProvider, GoogleAuthProvider, signInWithRedirect,
getRedirectResult, onAuthStateChanged, signOut } from "https://www.gstatic.com/firebasejs/10.14.1//firebase-auth.js";
//Google SignIn button click
googleSignIn.addEventListener('click', async()=>{
console.log('Google button clicked');
await signInWithRedirect(auth, googleProvider);
getRedirectResult(auth)
.then((result) => {
// This gives you a Google Access Token. You can use it to access Google APIs.
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
console.log("token is");
// The signed-in user info.
const user = result.user;
createFireStoreUser(user.uid, user.displayName);
// IdP data available using getAdditionalUserInfo(result)
// ...
}).catch((error) => {
// Handle Errors here.
console.log("error is");
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
});
});