Skip to content

Firebase Auth error

Firebase Auth: auth/invalid-verification-code

auth/invalid-verification-code is the Firebase Auth error for an SMS code that doesn’t match the code Firebase sent for that verification. It usually comes from a typo, an older code after a resend, or a fictional test number with a different code.

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

Keep the ConfirmationResult or verification ID from the latest signInWithPhoneNumber call, and confirm the code against that one. Strip spaces from the input, let the user resend, and for fictional test numbers enter the code set in the Firebase console.

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 Firebase rejects the code, and the fix

  1. 01

    The user typed the wrong code

    “sign in the user by passing the code to the confirm method of the ConfirmationResult object” Firebase, Phone authentication (web)

    Six digits are easy to mistype. Show a clear message, keep the input, and offer a resend after a short wait.

    try {
      const result = await confirmationResult.confirm(code.replace(/\s/g, ''));
    } catch (error) {
      if (error.code === 'auth/invalid-verification-code') {
        showMessage('That code doesn’t match. Check the SMS or request a new code.');
      }
    }
  2. 02

    An old code after a resend

    After a resend, the user may type the code from the first SMS, which belongs to the earlier verification. Always confirm against the newest ConfirmationResult, and tell the user to use the latest message.

  3. 03

    The wrong verification ID is used

    On Android and iOS, an app restart or a screen rebuild can drop the verification ID or leave an older one in use. A missing or invalid ID gives auth/missing-verification-id or auth/invalid-verification-id; an older ID with a new code fails as a mismatch. Keep the latest ID somewhere that survives.

  4. 04

    A fictional test number uses its own code

    “You can set up fictional phone numbers for development using the Firebase console.” Firebase, Test with fictional phone numbers

    Also check: test numbers set in the console only accept the code you set there. No real SMS is sent to them.

Checked against the vendor’s docs on : Firebase docs: Phone authentication (web).

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/invalid-phone-number · Firebase phone auth invalid-app-credential · Firebase auth/missing-or-invalid-nonce · Firebase auth/invalid-action-code

Questions

More on this error

Is an expired code the same error?

No. An expired code gives auth/code-expired. Ask the user to request a new code.

Do fictional numbers cost SMS quota?

No. Firebase says fictional numbers let you test without consuming your usage quota and without sending a real SMS.

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.