-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Firebase AI] Add x-ios-bundle-identifier header to requests
#15515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This change adds the `x-ios-bundle-identifier` header to requests made by `GenerativeAIService`. The value is set to `Bundle.main.bundleIdentifier` if available. This header is sent unconditionally. A test assertion has been added to `GenerativeModelTestUtil.swift` to verify the presence and correctness of this header in unit tests.
x-ios-bundle-identifier header to requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly adds the x-ios-bundle-identifier header to support API key restrictions for iOS applications. The changes are applied to GenerativeAIService and LiveSessionService, and the unit tests have been updated accordingly. I've identified a small code duplication in GenerativeAIService.swift and a minor inconsistency in LiveSessionService.swift. Addressing these points will improve the code's clarity and maintainability.
FirebaseAI/Sources/Types/Internal/Live/LiveSessionService.swift
Outdated
Show resolved
Hide resolved
|
Verified locally that requests missing the header produce Full Response |
Thanks for verifying! |
Added the
x-ios-bundle-identifierheader toGenerativeAIServiceandLiveSessionServicerequests to support iOS application API key restrictions. This requires callers to set thex-ios-bundle-identifierheader to match one of the iOS Bundle IDs specified for the API key. This addresses #15475.Important: We still strongly recommend the use of Firebase AppCheck instead of, or in addition to, API key restrictions.