Commit 81f5614
[AI] Attach X-Firebase-AppCheck header on Live API WebSocket handshake (#8063)
Fixes #8060
## Summary
`APIController.getWebSocketSession()` did not call
`applyHeaderProvider()`, so the `X-Firebase-AppCheck` header was missing
from the WebSocket upgrade request. This broke Gemini Live whenever App
Check was enforced on AI Logic, while HTTPS methods on the same class
continued to work because they route through either
`applyHeaderProvider()` directly or `postStream` (which calls it
internally).
## Fix
`applyHeaderProvider()` is `suspend` and Ktor's `webSocketSession { }`
config lambda is non-suspend, so the fix pre-fetches headers in the
outer suspend context and applies them synchronously inside the lambda.
## Test plan
- [x] Added unit test `headers from HeaderProvider are added to the
WebSocket handshake` mirroring the existing HTTP-path test — passes.
- [x] Existing `RequestFormatTests` suite still passes (`./gradlew
:ai-logic:firebase-ai:test`).
- [x] Code formatted with `./gradlew
:ai-logic:firebase-ai:spotlessApply`.
- [x] Manual E2E reproduction: built the SDK locally, consumed via
`mavenLocal()` in a real app, confirmed `liveModel().connect()` succeeds
with App Check enforced on AI Logic.
---------
Co-authored-by: Jackson E J <jackson@entri.me>
Co-authored-by: Vinay Guthal <vguthal@google.com>1 parent c1aabba commit 81f5614
3 files changed
Lines changed: 64 additions & 12 deletions
File tree
- ai-logic/firebase-ai
- src
- main/kotlin/com/google/firebase/ai/common
- test/java/com/google/firebase/ai/common
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
Lines changed: 25 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
259 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
260 | 271 | | |
261 | 272 | | |
262 | 273 | | |
| |||
306 | 317 | | |
307 | 318 | | |
308 | 319 | | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
319 | 332 | | |
320 | 333 | | |
321 | 334 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
420 | 456 | | |
421 | 457 | | |
422 | 458 | | |
| |||
0 commit comments