# Firebase Auth: auth/invalid-verification-code

> Firebase phone sign-in fails with auth/invalid-verification-code. The code doesn’t match its verification: confirm with the newest ConfirmationResult.

Canonical: https://app369.com/fix/firebase-auth-invalid-verification-code/
Last updated: 2026-11-09

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.

**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**](https://app369.com/fixed-price/flutter-firebase-bug-fix/) starts with a fixed-price diagnosis, then a fixed price for the fix before any fix work.

## **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)**](https://firebase.google.com/docs/auth/web/phone-auth) 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**](https://firebase.google.com/docs/auth/web/phone-auth) 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 November 9, 2026: [Firebase docs: Phone authentication (web)](https://firebase.google.com/docs/auth/web/phone-auth).

## **Rather hand it over?**

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

- [from $450**App Fix Ticket**One reproducible bug in an existing mobile or web app, diagnosed and fixed.**See scope and start**](https://app369.com/fixed-price/flutter-firebase-bug-fix/)
- [from $450**AI-Built App Rescue**A 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**](https://app369.com/fixed-price/ai-app-rescue/)

[**All 127 Fiverr reviews**](https://app369.com/reviews/)

Related: [**Firebase auth/invalid-phone-number**](https://app369.com/fix/firebase-auth-invalid-phone-number/) · [**Firebase phone auth invalid-app-credential**](https://app369.com/fix/firebase-phone-auth-invalid-app-credential/) · [**Firebase auth/missing-or-invalid-nonce**](https://app369.com/fix/firebase-auth-missing-or-invalid-nonce/) · [**Firebase auth/invalid-action-code**](https://app369.com/fix/firebase-auth-invalid-action-code/)

Questions

## **More on this error**

<details>

<summary>**Is an expired code the same error? **+</summary>

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

</details>

<details>

<summary>**Do fictional numbers cost SMS quota? **+</summary>

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

</details>

<details>

<summary>**Can you fix it for me? **+</summary>

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.

</details>

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.

[**Describe your problem **→](https://app369.com/contact/) [**All fixes**](https://app369.com/fix/)