Auth
Your Firebase AI Logic calls are blocked without an App Check token
Cataloged November 9, 2026 · Firebase · Cursor · Bolt · v0 · Lovable · Replit
Symptom
The rest of the app still loads. Sign-in works. The Gemini call does not. Firebase's AI Logic FAQ and the App Check guide say that starting November 2, 2026, Firebase will automatically enforce App Check for Firebase AI Logic in a project where it is not already enforced. A request with no valid App Check token is unverified, and the same pages say it will be blocked. That includes a released build that never initialized App Check, and it includes localhost, which the debug-provider guide says does not qualify as a valid device. The October 27, 2026 Firebase release notes are where the delay control was added. On the Firebase AI Logic row under Security > App Check > APIs, the Enforces date can be moved, and the last date those docs allow is January 21, 2027. Moving that date does not put a token in an old build, and the same docs say the Gemini API stays open to abuse until enforcement is on. Firebase's error-code page documents two 403 PERMISSION_DENIED messages for projects that are not enforced yet. One says To access this model, you must enforce Firebase App Check, when the request has no valid token and the model is one Firebase describes as common for malicious actors to abuse. The other says Firebase AI Logic has been deactivated in this project, when AI Logic is enabled and the project has no recent usage.
Root cause
Firebase AI Logic is the proxy in front of the Gemini API. The App Check guide says requests from the Firebase AI Logic SDKs are sent to the Firebase AI Logic API, firebasevertexai.googleapis.com, and App Check is checked there before the request is allowed through to a Gemini model. It protects both the Gemini Developer API and the Agent Platform Gemini API, formerly Vertex AI. A valid token attests that the request came from your app, from an untampered device, or both. The production providers named on that guide are DeviceCheck, App Attest, or reCAPTCHA Enterprise on Apple platforms, Play Integrity or reCAPTCHA Enterprise on Android, and reCAPTCHA Enterprise on the web. Flutter can use those same providers. The web provider has to be a score-based reCAPTCHA Enterprise key, with the checkbox challenge left unselected, and that same key is what you register on the Apps tab. The reCAPTCHA Enterprise guide says initializeAppCheck has to run before the app uses any Firebase service, and the SDK does not refresh tokens unless isTokenAutoRefreshEnabled is true. The getting-started page's web sample for sending a prompt calls getAI with GoogleAIBackend and then getGenerativeModel. That sample does not call initializeAppCheck, so a client copied from it sends no token. Since early July 2026, the guided setup in the Firebase console enforces App Check for AI Logic during setup. The getting-started guide says a Firebase AI Logic row that still says Unenforced has to be enforced by hand. The FAQ's November 2, 2026 rule is the one that covers projects still unenforced on that date: Firebase will automatically enforce App Check unless the Enforces date was moved. After enforcement, unverified requests are blocked, including app versions already in users' hands. Localhost and CI are not valid devices. A debug build sets self.FIREBASE_APPCHECK_DEBUG_TOKEN to true before initializeAppCheck, and the browser console prints a line that begins AppCheck debug token. That token has to be registered under Security > App Check > Apps > Manage debug tokens before the backend accepts it. The debug-provider page says not to add localhost to the reCAPTCHA allowed domains, because that would let anyone run the app from their own machine, and not to commit the token or ship the debug build. On the Firebase JS SDK before v9, the flag is read at import time, so it has to be set before the bundle loads. The two 403 messages on the error-code page, last updated November 6, 2026, are the not-yet-enforced cases. To access this model, you must enforce Firebase App Check means there is no valid token and the model is one Firebase says is common for malicious actors to abuse, so Firebase blocks that model until the request carries a valid token. Firebase AI Logic has been deactivated in this project means AI Logic is enabled, the project has no recent usage, and App Check is not enforced, so Firebase deactivated AI Logic until you enforce it. If that second 403 is still there after enforcement, the error-code page says to check replay protection, including Monitor only. While replay protection is on, only a limited-use token counts, and a session token does not. On the web, limited-use tokens are useLimitedUseAppCheckTokens set to true on getAI. The App Check guide lists web v12.14.0 or later as the minimum for replay protection. Limited-use tokens last 5 minutes, and that TTL is not adjustable. The same page says that if you turn replay protection off to clear the error, resend a request and wait about a day before turning it back on, because project activity is re-evaluated daily. The guide calls unenforcing App Check strongly not recommended. While it is off, the Gemini API is open to abuse, and the November 2 rule still stands. The FAQ and the App Check page were last updated November 6 and November 5, 2026, and they still state the November 2 rule in that form.
Before and after
The before line is the web sample under Send a request to a model on the Firebase AI Logic getting-started page. It creates the Gemini client and does not call initializeAppCheck. The after lines are the reCAPTCHA Enterprise web setup, which has to run before the app uses Firebase. RECAPTCHA_KEY stands in for the score-based key registered under Security > App Check. Do not paste a real key, and do not add localhost to that key.
Before
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });After
initializeAppCheck(firebaseApp, {
provider: new ReCaptchaEnterpriseProvider(RECAPTCHA_KEY),
isTokenAutoRefreshEnabled: true,
});
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });Fix prompt
In this project only. Do not scan or test anyone else's app. Do not open anyone else's Firebase project. Do not print API keys, reCAPTCHA keys, App Check tokens, debug tokens, or environment variable values. When you mention a variable, print the name only. 1. Find whether this project calls Firebase AI Logic. Search for getAI, getGenerativeModel, GoogleAIBackend, firebase/ai, FirebaseAI, firebase_ai, and GenerativeBackend.googleAI. If this project does not call Firebase AI Logic, say so and stop. 2. Report whether this project initializes App Check before those calls, with the file and line. On the web, that call is initializeAppCheck from firebase/app-check. On Apple platforms, the debug sample in the App Check guide sets AppCheck.setAppCheckProviderFactory before FirebaseApp.configure. On Android, the debug sample calls installAppCheckProviderFactory. On Flutter, the debug sample calls FirebaseAppCheck.instance.activate. Do not print tokens. 3. If the client never initializes App Check, it sends no token. Firebase's FAQ says that starting November 2, 2026, Firebase will automatically enforce App Check for Firebase AI Logic unless the project delayed it, and that a request with no valid token will be blocked. Do not unenforce App Check. The App Check guide calls that strongly not recommended, because the Gemini API is then open to abuse. 4. If this project is a web app, add initializeAppCheck before any other Firebase use. Use ReCaptchaEnterpriseProvider with the score-based key this project already uses for App Check, and set isTokenAutoRefreshEnabled to true. The reCAPTCHA Enterprise guide says the checkbox challenge stays off, and that the key registered in the Firebase console has to be the same key passed to the provider. Read the key from the env var this project already has for it. Do not invent a key, do not hardcode a new one, and do not add localhost to that key's domains. Show me the diff. If no key exists yet, stop and tell me to create a score-based web key in reCAPTCHA Enterprise and register the app under Security > App Check > Apps. You cannot create that key. 5. For localhost on this project's own web app, set self.FIREBASE_APPCHECK_DEBUG_TOKEN to true in the debug build only, before initializeAppCheck. Tell me to open my own app locally, read the line in my own browser console that begins AppCheck debug token, and register that token myself under Security > App Check > Apps > Manage debug tokens. Do not print the token, do not commit it, and do not ship the debug build. If package.json shows a Firebase JS SDK older than v9, the flag is read at import time, so set it before the bundle loads, as the debug-provider page describes. Do not add localhost to the reCAPTCHA allowed domains. 6. If this project is Apple, Android, or Flutter, keep the debug provider in the debug build only. Name the production provider from the App Check guide and show me a diff that initializes it: DeviceCheck, App Attest, or reCAPTCHA Enterprise on Apple; Play Integrity or reCAPTCHA Enterprise on Android; reCAPTCHA Enterprise on web; Flutter can use those same providers. Do not ship a debug provider factory in the release build. 7. If I say a released build cannot send a token yet, do not change the Firebase console yourself. Tell me the delay the docs describe: Security > App Check > APIs, the Firebase AI Logic row, the Enforces date picker, then Save. The last date the docs allow is January 21, 2027. Say that delaying leaves the Gemini API open to abuse, and that old binaries stay unverified until users install a build that sends a token. 8. If my own generate call still returns the 403 that says Firebase AI Logic has been deactivated in this project after App Check is enforced, check whether replay protection is on for Firebase AI Logic, including Monitor only. While it is on, only a limited-use token counts. On the web, that is useLimitedUseAppCheckTokens set to true on getAI, and the App Check guide says the web SDK has to be v12.14.0 or later for replay protection. Do not turn replay protection off unless I ask. If I ask, the error-code page says to resend a request and wait about a day before turning it back on. Do not print keys. Do not edit unrelated files.
Paste this into the coding tool that has your own project open.
2-minute self-check
These steps are for an app you own. Do not run them against someone else's project.
- In your own Firebase console, open Security > App Check > APIs and read the Firebase AI Logic row. Unenforced means the November 2, 2026 rule in Firebase's FAQ applies unless the Enforces date on that row was moved. The last date those docs allow is January 21, 2027. Do not open a project you do not own.
- In your own repo, search for getAI, FirebaseAI, firebase/ai, and generativeModel. If those calls exist and the same app never calls initializeAppCheck, AppCheck.setAppCheckProviderFactory, installAppCheckProviderFactory, or FirebaseAppCheck.instance.activate, the client is not set up to send a token.
- On your own machine, use your own app's Gemini feature and look at your own browser or device log. A 403 PERMISSION_DENIED that says To access this model, you must enforce Firebase App Check, or Firebase AI Logic has been deactivated in this project, is one of the two messages on Firebase's error-code page. Do not paste an API key, a reCAPTCHA key, or an App Check token out of that log, and do not send the request to anyone else's project.
- In your own production build, search for FIREBASE_APPCHECK_DEBUG_TOKEN. The debug-provider page says a debug token and a debug build must stay off production, and that localhost must not be added to a reCAPTCHA key that is deployed. Do not print the token.
Common questions
Gemini worked last week. Why does the call fail now?
Firebase's AI Logic FAQ says that starting November 2, 2026, Firebase will automatically enforce App Check for Firebase AI Logic if the project has not already enforced it, and that a request with no valid App Check token will be blocked. The October 27, 2026 release notes are where the delay control was announced. A client that calls getAI or the native Firebase AI Logic SDK and never initializes App Check sends no token. Localhost fails for the same reason: the debug-provider guide says localhost does not qualify as a valid device once enforcement is on. The error-code page, last updated November 6, 2026, names two 403 PERMISSION_DENIED messages for projects that are not enforced yet: To access this model, you must enforce Firebase App Check, and Firebase AI Logic has been deactivated in this project.
Can I turn App Check off so the button works again?
The App Check guide calls unenforcing App Check strongly not recommended. While it is off, the Gemini API is open to abuse, and the FAQ still says enforcement is required starting November 2, 2026. The temporary control is the Enforces date on the Firebase AI Logic row under Security > App Check > APIs. The last date those docs allow is January 21, 2027. Moving that date does not add a token to a build that never sends one. Those versions stay unverified until users install a build that initializes App Check.
I added reCAPTCHA and localhost still fails. Is the key wrong?
The debug-provider guide says not to fix localhost by adding localhost to the reCAPTCHA allowed domains. That would let anyone run the app from their own machine. A debug build sets self.FIREBASE_APPCHECK_DEBUG_TOKEN to true before initializeAppCheck. The browser console prints a line that begins AppCheck debug token, and that token has to be registered under Security > App Check > Apps > Manage debug tokens. Do not commit the token or ship the debug build. On a production deploy, the reCAPTCHA Enterprise guide says to call initializeAppCheck with ReCaptchaEnterpriseProvider before any other Firebase use, with isTokenAutoRefreshEnabled set to true, using the same score-based key you registered. The checkbox challenge stays off.
Longer guide
- Firebase security rules allow read, write if true: check your own project
What Firebase's open rules and the CLI's 30-day Firestore template allow, what one public-web scan counted, and a check you run only on a project you own.
Sources
- Firebase release notes: delay App Check auto-enforcement for Firebase AI Logic (October 27, 2026; enforcement date November 2, 2026)
- Firebase AI Logic: Prevent Gemini API abuse with Firebase App Check (page last updated November 5, 2026)
- Firebase AI Logic: FAQ and troubleshooting, App Check enforcement (page last updated November 6, 2026)
- Firebase AI Logic: Error codes, the two App Check 403 PERMISSION_DENIED messages (page last updated November 6, 2026)
- Firebase App Check: debug provider in web apps (page last updated November 5, 2026)
- Firebase App Check: reCAPTCHA Enterprise in web apps (page last updated November 5, 2026)
- Firebase AI Logic: Get started with the Gemini API using the Firebase AI Logic SDKs