[firebase_ai] Live sessions on web don't send the App Check token
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- api, authentication
Research direction
Start with lib/src/live_session.dart and live_model.dart, then check how web WebSocket connections can pass Firebase App Check and Auth tokens and whether the backend accepts them in the query or setup message. Reproduce the reported Chrome connection with App Check enforced; done means Live sessions send the required tokens on web and the server no longer closes them with code 1008.
Written by the indexing model from the issue text.
Description
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
- Enforce App Check for Firebase AI Logic and register a web debug token.
- On Chrome, connect a Live session, for example
FirebaseAI.googleAI().liveGenerativeModel(model: 'gemini-3.8-live')andconnect(). - 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.
- Dominant language
- Dart
- Stars
- 9.3k
- Forks
- 4.1k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 78
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/flutterfire
-
🚀 [firebase_core] Bump Firebase C++ SDK (14.1.0 → 14.2.0)Possibly taken @SelaseKay claimed this today. OpenNeeds Attention type: enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
firebase/flutterfire#18977 · 1 comment ·
Maintainers usually reply within 1 day
-
[firebase_core_web]: Firebase.initializeApp never completes when a Firebase JS SDK script fails to loadPossibly taken @LasseLegarth claimed this 5 days ago. OpenNeeds Attention platform: web plugin: core reproduced type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
firebase/flutterfire#18964 · 1 comment ·
Maintainers usually reply within 1 day
-
Needs Attention platform: android plugin: crashlytics type: enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
firebase/flutterfire#18951 · 2 comments ·
Maintainers usually reply within 1 day
-
[cloud_firestore][Windows] Invalid field names (empty or `__x__`) close the app instead of throwing a FirebaseExceptionPossibly taken @SelaseKay claimed this 6 days ago. OpenNeeds Attention platform: windows plugin: cloud_firestore reproduced type: bug type: crash
Difficulty 4/5 3-5 days Newbie friendliness 52/100
firebase/flutterfire#18928 · 1 comment ·
Maintainers usually reply within 1 day
-
Needs Attention plugin: ai type: enhancement
Difficulty 3/5 1-2 days Newbie friendliness 67/100
firebase/flutterfire#18917 ·
Maintainers usually reply within 1 day
All issues in firebase/flutterfire
Similar issues
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
StabilityNexus/Zplit#77 · 1 comment ·
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
-
agent: is checked on a wrapper holding several checkables answers from the first one in tree orderOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
AlphaWaveSystems/flutter-probe#865 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ubuntu/app-center#2306 ·
Maintainers usually reply within 1 day