Skip to content

firebase_ai: 403 The Caller Do not have permmission #17748

@Yazan99sh

Description

@Yazan99sh

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Other

Which platforms are affected?

Web

Description

After following the official "Get Started with the Gemini API on Web" documentation, all calls to the Gemini model using the firebase_ai package fail with a 403 Forbidden: The caller does not have permission error.

This issue occurs exclusively when running the Flutter app in a web browser on localhost. The exact same API key and request configuration work perfectly when tested directly via Postman, which confirms that the API key is valid and the Generative Language/Vertex AI API is enabled and functioning correctly on the backend.

The error seems to be related to the context of the request originating from the browser (specifically localhost) rather than an issue with the API key or cloud project permissions themselves.

Reproducing the issue

Set up a new Flutter project and configure it for Web.

Initialize Firebase for the project using flutterfire configure.

Follow the official documentation to set up the Firebase AI SDK: Get Started with the Gemini API on Web

Implement a basic call to the model:

Dart

import 'package:firebase_ai/firebase_ai.dart';
// ...
final model = FirebaseAI.instance.googleAI(model: 'gemini-2.5-flash');
final response = await model.generateContent([Content.text('Why is the sky blue?')]);
print(response.text);

Run the app locally on Chrome: flutter run -d chrome

Trigger the generateContent call.

Observe the 403 permission error in the browser's developer tools network tab.

  1. Expected behavior

The API call from the Flutter Web app on localhost should succeed and return a valid response from the Gemini model, consistent with the behavior observed in Postman.

  1. Actual behavior

The request fails with a 403 Forbidden status code. The response body typically contains an error message like: The caller does not have permission.

Firebase Core version

4.1.1

Flutter Version

3.35.4

Relevant Log Output

ServerFailure(Failed to parse JSON response: The caller does not have permission)

Flutter dependencies

environment:
sdk: ^3.7.0
firebase_core: ^4.1.1
firebase_messaging: ^16.0.2
firebase_analytics: ^12.0.2
firebase_auth: ^6.1.0
firebase_ai: ^3.3.0
firebase_app_check: ^0.4.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked: customer-responseWaiting for customer response, e.g. more information was requested.platform: webIssues / PRs which are specifically for web.plugin: ailabel issues for firebase_ai plugintype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions