Skip to content

Firebase Auth error

Firebase Auth: auth/credential-already-in-use

auth/credential-already-in-use is the Firebase Auth error for linking a provider account that already belongs to another Firebase user. It often hits apps that start users as anonymous guests and later ask them to sign in with Google or Apple.

Rather hand it over? App Fix Ticket: One reproducible bug in an existing mobile or web app, diagnosed and fixed.The Fix is $1,200 in total. The $450 Diagnosis is optional and credited toward it.

Full refund if Simon can’t take it on once he sees your project, or if you cancel before work starts. Refund terms.

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 fixes one reproducible bug at a fixed price, with an optional Diagnosis that is credited toward the fix.

Why the link fails, and the fix

  1. 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);
      }
    }
  2. 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.

  3. 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.

  4. 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.

“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
A buyer in the United States, July 2022. Shopify on Fiverr
Read 126 of the 127 Fiverr reviews

Related: Firebase auth/provider-already-linked · Firebase account-exists-with-different-credential · Firebase auth/email-already-in-use · Firebase auth/missing-or-invalid-nonce

Questions

More on this error

How is this different from account-exists-with-different-credential?

account-exists-with-different-credential happens at sign-in, when the email belongs to a user with another provider. credential-already-in-use happens when linking, when the provider account itself already belongs to another user.

Can I merge two Firebase users into one?

Not with linking. Copy the data you need to the account you keep, then delete the other user.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it. If you already know the cause, you can pay for the fix directly; if not, start with a written diagnosis, which is credited toward the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. 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.

A different error?

Ask Simon for a price range

Send the error and what you were doing. Simon replies by email, usually within one business day, with a price range.