flutterfire_cli icon indicating copy to clipboard operation
flutterfire_cli copied to clipboard

[bug]: Configure Force Unwonted Firebase Project

Open almogtovim opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

CLI Version

0.2.7

Firebase Tools version

13.3.0

Flutter Doctor Output

[✓] Flutter (Channel stable, 3.16.9, on macOS 14.2.1 23C71 darwin-arm64, locale en-IL) • Flutter version 3.16.9 on channel stable at /Users/almogtovim/Development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 41456452f2 (4 weeks ago), 2024-01-25 10:06:23 -0800 • Engine revision f40e976bed • Dart version 3.2.6 • DevTools version 2.28.5

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/almogtovim/Library/Android/sdk • Platform android-34, build-tools 33.0.0 • ANDROID_HOME = /Users/almogtovim/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15C500b • CocoaPods version 1.15.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.86.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.82.0

[✓] Connected device (3 available)
• Pixel 7 (mobile) • 2B111FDH2006TF • android-arm64 • Android 14 (API 34) • macOS (desktop) • macos • darwin-arm64 • macOS 14.2.1 23C71 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 121.0.6167.184

[✓] Network resources • All expected network resources are available.

• No issues found!

Description

I am encountering an authentication issue with the Firebase CLI while trying to configure my Flutter project (sculab-app) with Firebase using the flutterfire config command. Despite correctly specifying my project ID, the Firebase CLI attempts to configure a different project (sculab-app-dev) than intended. This command fails only for (sculab-app) project and works ok for my other environments (dev and stg).

The command:

flutterfire config \
  --project=sculab-app \
  --ios-bundle-id=com.***.*** \
  --macos-bundle-id=com.***.*** \
  --android-app-id=com.***.***

Moreover, I get UNAUTHENTICATED error when running firebase projects:list --debug:

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "CREDENTIALS_MISSING",
        "domain": "googleapis.com",
        "metadata": {
          "service": "firebase.googleapis.com",
          "method": "google.firebase.service.v1beta1.FirebaseProjectService.ListFirebaseProjects"
        }
      }
    ]
  }
}

Steps to reproduce

Assuming that firebase_cli and flutterfire already installed:

  1. create flutter project
  2. open 3 different firebase projects: prod(europe-west6), dec(europe-west), stg(europe-west)
  3. create different flavors for android and ios
  4. running configure for dev environment:
flutterfire config \
  --project=sculab-app-dev \
  --ios-bundle-id=com.***.***.dev \
  --macos-bundle-id=com.***.***.dev\
  --android-app-id=com.***.***.dev

5.running configure for stg environment:

flutterfire config \
--project=sculab-app-stg \
--ios-bundle-id=com.***.***.stg \
--macos-bundle-id=com.***.***.stg\
--android-app-id=com.***.***.stg
  1. running configure for prod environment:
flutterfire config \
--project=sculab-app\
--ios-bundle-id=com.***.***.\
--macos-bundle-id=com.***.***\
--android-app-id=com.***.***

Force dev!

Expected behavior

Configuration should apply to sculab-app.

Screenshots

Screenshot 2024-02-20 at 20 41 33

Additional context and comments

Something weird that maybe related:

  1. The GOOGLE_APPLICATION_CREDENTIALS environment variable is not set (echo $GOOGLE_APPLICATION_CREDENTIALS returns nothing).
  2. I'm getting also warning: (node:35972) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead. (Use node --trace-deprecation ... to show where the warning was created)
  3. Projects are in different regions.

I tried already: Logged out and back into Firebase CLI (firebase logout & firebase login). Re-authenticated with firebase login --reauth. npm update

almogtovim avatar Feb 20 '24 18:02 almogtovim

Could you try using the latest dev version which is significantly improved. Run:

dart pub global activate flutterfire_cli 0.3.0-dev.19 --overwrite

Documentation: https://github.com/invertase/flutterfire_cli/blob/main/README.md

russellwheatley avatar Feb 29 '24 09:02 russellwheatley

Thanks for the answer, but the issue still persists. This issue is preventing me from releasing the app.

almogtovim avatar Feb 29 '24 13:02 almogtovim

Faced an issue where FlutterFire CLI incorrectly targeted sculab-app-dev instead of sculab-app. The problem is now resolved with the following steps:

  1. Reinstalled Firebase CLI via Homebrew for a clean and conflict-free setup.
  2. Removed any remaining Firebase CLI installations manually to clear potential conflicts.
  3. Updated all Firebase packages in my project to the newest versions.
  4. Ran firebase init to reconfigure Firebase settings properly.
  5. Deactivated and reactivated FlutterFire CLI to the latest version, ensuring up-to-date functionality.
  6. Logged out and back into Firebase CLI, refreshing my authentication credentials to fix the UNAUTHENTICATED error.

These actions corrected the project targeting and authentication issues, allowing the correct Firebase configuration for sculab-app.

almogtovim avatar Feb 29 '24 15:02 almogtovim

Glad you were able to resolve it 🙏

russellwheatley avatar Jul 02 '24 09:07 russellwheatley