Skip to content

[firebase_ai] Live sessions on web don't send the App Check token #18938

Open

Description

@adesinah

Bug

On web, a LiveGenerativeModel session doesn't send the App Check token, so when App Check is enforced for Firebase AI Logic the server closes every Live session right after it connects:

WebSocket Closed, closeCode: 1008, closeReason: Firebase App Check token is invalid.

Non-Live requests in the same app pass App Check with the same token.

Cause

LiveSession._defaultConnector in lib/src/live_session.dart drops the headers on web:

static WebSocketChannel _defaultConnector(
        Uri uri, Map<String, String> headers) =>
    kIsWeb
        ? WebSocketChannel.connect(uri)
        : IOWebSocketChannel.connect(uri, headers: headers);

live_model.dart builds those headers with BaseModel.firebaseTokens(...), so the X-Firebase-AppCheck header (and the Auth token) only reach the server on native platforms. On web the token is in neither the URL (only ?key=) nor the setup message. Browsers can't set headers on a WebSocket, so the token needs to travel another way, for example as a query parameter or in the setup message, if the backend accepts one.

Same code in firebase_ai 3.15.0, 4.0.0, 5.0.0 and 5.1.0.

Repro

  1. Enforce App Check for Firebase AI Logic and register a web debug token.
  2. On Chrome, connect a Live session, for example FirebaseAI.googleAI().liveGenerativeModel(model: 'gemini-3.8-live') and connect().
  3. The server closes the socket with 1008 "Firebase App Check token is invalid".

Seen with the Gemini Developer API and with Agent Platform (us-central1). Found through the Genkit Firebase AI plugin: genkit-ai/genkit-dart#730.

Versions

firebase_ai 5.1.0, Flutter 3.47.9, Chrome.

Activity

  1. added
    Needs AttentionThis issue needs maintainer attention.
    platform: webIssues / PRs which are specifically for web.
    plugin: ailabel issues for firebase_ai plugin
    type: bugSomething isn't working
    on Nov 11, 2026
  2. SelaseKay commented on Nov 11, 2026

    @SelaseKay
    Contributor

    Hi @adesinah, thanks for the report. I'm looking into this.

  3. SelaseKay commented on Nov 11, 2026

    @SelaseKay
    Contributor

    Hi @adesinah, thanks again for the report.

    This is valid. The browser WebSocket API cannot set those headers, and the Live backend does not currently accept the App Check token on the URL or in the setup message either. Firebase is tracking the same limitation in the JavaScript SDK and has said a backend change is required before a browser client can send the token: firebase/firebase-js-sdk#10018.

    That change is not available yet, so there is no FlutterFire-only fix for web. I'll keep this opened so we can keep track of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions