Short answer
Catch the error and take the credential from it. Save what the current user has, sign in with that credential to reach the existing account, then copy the saved data over and delete the old guest user from your server with the Admin SDK. Don’t try to link the same credential again.
Rather not fix it yourself? App Fix Ticket starts with a fixed-price diagnosis, then a fixed price for the fix before any fix work.
Why the link fails, and the fix
01
An anonymous guest signs in with an existing account
“Account linking will fail if the credentials are already linked to another user account.” Firebase, Link multiple auth providers
The guest is one Firebase user, and the Google account already belongs to another. Firebase won’t join two users by linking, so the app has to switch to the existing one and move the guest’s data.
import { getAuth, linkWithPopup, signInWithCredential, GoogleAuthProvider } from 'firebase/auth'; const auth = getAuth(); const guest = auth.currentUser; try { await linkWithPopup(guest, new GoogleAuthProvider()); } catch (error) { if (error.code === 'auth/credential-already-in-use') { const cred = GoogleAuthProvider.credentialFromError(error); const guestData = await loadData(guest.uid); // your own data layer const { user } = await signInWithCredential(auth, cred); await mergeData(user.uid, guestData); } }02
The guest data is read too late
After signInWithCredential the app is signed in as the other user, and rules may stop it reading the guest’s documents. Read and keep the guest data before you switch.
03
The old guest user is left behind
Each failed upgrade can leave an empty anonymous user. After the merge the app is signed in as the other user, so delete the guest from your server with the Admin SDK, or let a scheduled cleanup remove old anonymous accounts.
04
A signed-in user links someone else’s account
Also check: on a shared device, a user can pick another person’s Google account in the chooser. Show which account is in use and let the user choose to switch rather than merging silently.
Checked against the vendor’s docs on : Firebase docs: Link multiple auth providers.
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
“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
Related: Firebase auth/provider-already-linked · Firebase account-exists-with-different-credential · Firebase auth/email-already-in-use · Firebase phone auth invalid-app-credential