Description
HI i'm trying to enable API Key application restriction but with no avail since the GenerativeAIService urlRequest lack the "x-ios-bundle-identifier". After i added the header in this function: private func urlRequest<T: GenerativeAIRequest>(request: T) async throws -> URLRequest {}, the application restriction worked.
Reproducing the issue
- Edit the API Key that was used for Firebase AI Logic API and Generative Language API in google cloud console.
- Enable application restrictions with your app bundle id.
- Send a
generateContent request.
Firebase SDK Version
12.3
Xcode Version
26.0.1
Installation Method
CocoaPods
Firebase Product(s)
AI Logic
Targeted Platforms
iOS
Relevant Log Output
GenerateContentError
▿ internalError : 1 element
▿ underlying : BackendError
- httpResponseCode : 403
- message : "Requests from this iOS client application <empty> are blocked."
- status : FirebaseAI.RPCStatus.permissionDenied
▿ details : 2 elements
▿ 0 : ErrorDetails
- type : "type.googleapis.com/google.rpc.ErrorInfo"
▿ reason : Optional<String>
- some : "API_KEY_IOS_APP_BLOCKED"
▿ domain : Optional<String>
- some : "googleapis.com"
▿ metadata : Optional<Dictionary<String, String>>
▿ some : 3 elements
▿ 0 : 2 elements
- key : "service"
- value : "firebasevertexai.googleapis.com"
▿ 1 : 2 elements
- key : "iosBundleId"
- value : "<empty>"
▿ 2 : 2 elements
- key : "consumer"
- value : redacted
▿ 1 : ErrorDetails
- type : "type.googleapis.com/google.rpc.LocalizedMessage"
- reason : nil
- domain : nil
- metadata : nil
If using Swift Package Manager, the project's Package.resolved
If using CocoaPods, the project's Podfile.lock
Description
HI i'm trying to enable API Key application restriction but with no avail since the
GenerativeAIServiceurlRequest lack the "x-ios-bundle-identifier". After i added the header in this function:private func urlRequest<T: GenerativeAIRequest>(request: T) async throws -> URLRequest {}, the application restriction worked.Reproducing the issue
generateContentrequest.Firebase SDK Version
12.3
Xcode Version
26.0.1
Installation Method
CocoaPods
Firebase Product(s)
AI Logic
Targeted Platforms
iOS
Relevant Log Output
If using Swift Package Manager, the project's Package.resolved
If using CocoaPods, the project's Podfile.lock