auth/invalid-api-key Google Cloud / Firebase Origin: Platform & cloud OSI layer 7 · Application Last updated 18 Nov 2026

Firebase: auth/invalid-api-key — Your API key is invalid, please check you have copied it correctly

The web config's apiKey is wrong, missing or restricted.

Exact message you may see Firebase: Error (auth/invalid-api-key).Your API key is invalid, please check you have copied it correctlyAPI key not valid. Please pass a valid API key.INVALID_API_KEY Firebase
Seen on: Firebase JavaScript

Meaning

Copy the config from Project settings → Your apps, make sure environment variables are actually loaded at build time (NEXT_PUBLIC_, VITE_), and in Google Cloud check API key restrictions (HTTP referrers, API restrictions allowing Identity Toolkit).

Common causes

  • apiKey undefined (env var not loaded)
  • Key from another project
  • API key restrictions blocking the origin
  • Typo/copy error
  • Wrong app config used per environment

⚡ Quick fix

  1. Re-copy the Firebase config
  2. Verify env vars at build time
  3. Check key restrictions in Cloud Console → Credentials

Detailed fix by platform

JavaScript

  1. console.log(import.meta.env.VITE_FIREBASE_API_KEY) // must not be undefined

How to diagnose

  1. apiKey — Defined?
  2. Project — Right?
  3. Restrictions — Allow origin/API?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

API has not been used in project before or it is disabled — Google Cloud: 403 SERVICE_DISABLED — Cloud Resource Manager API has not been used in project 123456 before or it is disabled. Enable it by visiting (Google Cloud / Firebase)API has not been used…App Check — Firebase App Check: requests rejected (403 / app-check-token-is-invalid / attestation failed) (Google Cloud / Firebase)App Checkauth/account-exists-with-different-credential — Firebase Auth: account exists with a different credential (same email, other provider) (Google Cloud / Firebase)auth/account-exists-w…auth/email-already-in-use — Firebase Auth: auth/email-already-in-use — The email address is already in use by another account (Google Cloud / Firebase)auth/email-already-in…auth/invalid-custom-token — Firebase Auth: auth/invalid-custom-token — The custom token format is incorrect or the token is invalid (Google Cloud / Firebase)auth/invalid-custom-t…auth/operation-not-allowed — Firebase Auth: auth/operation-not-allowed — sign-in provider is not enabled (Google Cloud / Firebase)auth/operation-not-al…auth/requires-recent-login — Firebase Auth: auth/requires-recent-login — sensitive operation needs a recent sign-in (Google Cloud / Firebase)auth/requires-recent-…auth/unauthorized-domain — Firebase Auth: auth/unauthorized-domain — This domain is not authorized for OAuth operations for your Firebase project (Authentication)auth/unauthorized-dom…auth/inva…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.