[firebase_ai] Live sessions on web don't send the App Check token
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 领域
- api, authentication
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Dart
- 星标
- 9.3k
- 派生
- 4.1k
- 平均合并
- 2 天 10 小时
- 30 天内合并 PR
- 78
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/flutterfire 的其他 Issue
-
🚀 [firebase_core] Bump Firebase C++ SDK (14.1.0 → 14.2.0)可能已有人在做 @SelaseKay 今天认领。 未关闭Needs Attention type: enhancement
难度 2/5 1-3 小时 新手友好度 70/100
firebase/flutterfire#18977 · 1 条评论 ·
维护者通常 1 天内回复
-
[firebase_core_web]: Firebase.initializeApp never completes when a Firebase JS SDK script fails to load可能已有人在做 @LasseLegarth 于 5 天前认领。 未关闭Needs Attention platform: web plugin: core reproduced type: bug
难度 2/5 1-3 小时 新手友好度 62/100
firebase/flutterfire#18964 · 1 条评论 ·
维护者通常 1 天内回复
-
Needs Attention platform: android plugin: crashlytics type: enhancement
难度 4/5 3-5 天 新手友好度 48/100
firebase/flutterfire#18951 · 2 条评论 ·
维护者通常 1 天内回复
-
[cloud_firestore][Windows] Invalid field names (empty or `__x__`) close the app instead of throwing a FirebaseException可能已有人在做 @SelaseKay 于 5 天前认领。 未关闭Needs Attention platform: windows plugin: cloud_firestore reproduced type: bug type: crash
难度 4/5 3-5 天 新手友好度 52/100
firebase/flutterfire#18928 · 1 条评论 ·
维护者通常 1 天内回复
-
Needs Attention plugin: ai type: enhancement
难度 3/5 1-2 天 新手友好度 67/100
firebase/flutterfire#18917 ·
维护者通常 1 天内回复
查看 firebase/flutterfire 的全部 Issue
相似的 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 67/100
-
agent: is checked on a wrapper holding several checkables answers from the first one in tree order未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
AlphaWaveSystems/flutter-probe#865 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
ubuntu/app-center#2306 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 64/100
spotiflacapp/SpotiFLAC-Mobile#923 ·