Short answer
Keep the credential from the error, ask the user to sign in with the method they used before, then call linkWithCredential to add the new provider to that account. After that, both sign-in methods open the same user.
Why Firebase refuses the second provider, and the fix
01
One account per email, two providers
“To complete the sign in to the intended provider, the user has to sign first to the existing provider (Facebook) and then link to the former AuthCredential (Google ID token).” Firebase, Authenticate using Google with JavaScript (Handling account-exists-with-different-credential Errors)
The email already belongs to a user who signed in with another provider. Save the pending credential from the error, sign the user in with their existing method, then link.
try { await signInWithPopup(auth, new GithubAuthProvider()); } catch (e) { if (e.code === 'auth/account-exists-with-different-credential') { const pending = GithubAuthProvider.credentialFromError(e); // e.customData.email holds the email; show a button first, popups need a user click const { user } = await signInWithPopup(auth, new GoogleAuthProvider()); await linkWithCredential(user, pending); } }02
You can’t look up which provider the user had
“A list of sign-in methods for a specified email address is no longer returned when calling the createAuthUri REST API or the fetchSignInMethodsForEmail client SDK method on all platforms.” Google Cloud, Email enumeration protection
Older examples call fetchSignInMethodsForEmail to tell the user which provider to use. With email enumeration protection on, the default for new projects, it returns nothing. Ask the user how they signed up, or show the providers you support.
03
The existing account uses a password
If the earlier sign-up was email and password, sign the user in with it (or send a password reset), then link the pending social credential the same way.
04
Google sign-in rarely hits this
“A user logging in with Google will never cause this error when their account is hosted at Google” Firebase, Authenticate using Google with JavaScript
Firebase treats Google as authoritative for accounts hosted at Google, including Gmail and Google Workspace, so a user signing in with Google is not blocked by an existing account on that email. The error mostly comes from Facebook, GitHub, Twitter and other providers.
Checked against the vendor’s docs on : Firebase docs: Authenticate using Google with JavaScript; Firebase docs: Link multiple auth providers to an account; Google Cloud docs: Email enumeration protection.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
Related: Firebase auth/email-already-in-use · Firebase Google sign-in popup blocked · Firebase auth/operation-not-allowed · Firebase phone auth invalid-app-credential