Skip to content

Firebase Auth errorFirebase 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.

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

  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
All 127 Fiverr reviews

Related: Firebase auth/provider-already-linked · Firebase account-exists-with-different-credential · Firebase auth/email-already-in-use · Firebase phone auth invalid-app-credential

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: a written diagnosis first, then 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?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.