firebase-tools
firebase-tools copied to clipboard
emulator can't generate auth/account-exists-with-different-credential error
Operating System
macOS
Browser Version
Safari 16.5.2
Firebase SDK Version
10.1.0
Firebase SDK Product:
Auth
Describe your project's tooling
index.html with source tag.
Describe the problem
The Firebase Auth Emulator can't generate the auth/account-exists-with-different-credential error.
Steps and code to reproduce issue
The following code generates the aforementioned error without using the emulator.
const githubProvider = new GithubAuthProvider();
const googleProvider = new GoogleAuthProvider();
try {
await signInWithPopup(auth, githubProvider);
await signInWithPopup(auth, googleProvider);
await signInWithPopup(auth, githubProvider);
console.log("signed in successfully...oops.");
} catch (error) {
console.error(error);
if (error.code === 'auth/account-exists-with-different-credential') {
console.log("untrusted->trusted->untrusted");
}
}
This page explains that the error should be thrown, because I am signing in to an untrusted provider, then to a trusted, and then to the same untrusted one, using the same email in the whole process. And indeed, the error happens without the emulator. However, with it I am able to sign in successfully and instead the user gets 2 providers
The implementation of the Firebase Emulator resides within the firebase-tools GitHub repository. I'm going to move this issue there in hopes you can get better support.