FirebaseProjectNotFoundException: Firebase project id could not be found on this Firebase account - firebase

I found this project. After I added to index.html file the following Firebase configuration:
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js";
import { initializeApp } from "https://www.gstatic.com/firebasejs/8.6.1/firebase-auth.js";
import { initializeApp } from "https://www.gstatic.com/firebasejs/8.6.1/firebase-firestore.js";
import { initializeApp } from "https://www.gstatic.com/firebasejs/8.6.1/firebase-storage.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyDoO8efzrDVveeXvqqrc39D3XiqfsyoKeU",
authDomain: "diary-app-course-c6663.firebaseapp.com",
projectId: "diary-app-course-c6663",
storageBucket: "diary-app-course-c6663.appspot.com",
messagingSenderId: "1031493909898",
appId: "1:1031493909898:web:3cd71413645447b67c1c73"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
</script>
Next, I did the following steps on command line:
$ dart pub global activate flutterfire_cli
Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path.
You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):
export PATH="$PATH":"$HOME/.pub-cache/bin"
$ vim ~/.bashrc
$ source ~/.bashrc
$ flutterfire configure
$ curl -sL https://firebase.tools | bash
Unfortunately, I got this error:
$ flutterfire configure
i Found 1 Firebase projects. Selecting project diary-app-course.
FirebaseProjectNotFoundException: Firebase project id "diary-app-course" could not be found on this Firebase account.
$ grep -R diary-app-course *
web/index.html: authDomain: "diary-app-course-c6663.firebaseapp.com",
web/index.html: projectId: "diary-app-course-c6663",
web/index.html: storageBucket: "diary-app-course-c6663.appspot.com",
What did I miss?

Follow these steps:
Remove if their any default project exists in .firebaserc file.
Before:
{
"projects": {
"default": "diary-app-course"
}
}
After
{
"projects": {
}
}
Run this command in Firebase CLI:
firebase logout
Log in again:
firebase login
Again run this command in Firebase CLI
flutterfire configure
Hope this works.

flutterfire configure --project=diary-app-course-c6663
You could see your project id on your firebase link
for example : https://console.firebase.google.com/u/0/project/ this is your project id/database/xxxx/data

So, I made some change: If you are trying to logging in one account for registering firebase while creating new project, and at that time but if your android studio account was another one it will be problem.
Make sure to use one gmail account for registering new project and login that entered project
LOG OUT and LOG IN again
Please choose default account and create

Related

Can't find variable: IDBIndex on firebase/react native(expo)

I am developing a RN app in Expo with firebase as backend. So far, the app only uses firebase auth and firestore and for whatever reason, I randomly started getting the error of ReferenceError: Can't find variable: IDBIndex. I adjusted my firebase config to suit the v9 standards instead of using the compat package. I ensured my app was not using Google Analytics. I have also downgraded to firebase#9.1.0 which matches up with the expo documentation and this other similar post.
I have also git reverted into previous versions of the app (with earlier dependencies and code) when it was working but still got back the same error. When this occurred, I entirely reinstalled node and npm because I thought that was the only other possible reason this could be happening but that was to no avail as well (getting the same IDB error). I still think this is a firebase related issue, but I am pretty much all out of ideas as to what it could be.
Here is my firebase config:
import { initializeApp } from 'firebase/app'
import { getAuth, connectAuthEmulator } from "firebase/auth";
import { getFirestore, connectFirestoreEmulator } from "firebase/firestore";
import {
FIREBASE_API_KEY,
FIREBASE_AUTH_DOMAIN,
FIREBASE_PROJECT_ID,
FIREBASE_STORAGE_BUCKET,
FIREBASE_MESSAGING_SENDER_ID,
FIREBASE_APP_ID,
FIREBASE_MEASUREMENT_ID,
} from '#env';
const firebaseConfig = {
apiKey: FIREBASE_API_KEY,
authDomain: FIREBASE_AUTH_DOMAIN,
projectId: FIREBASE_PROJECT_ID,
storageBucket: FIREBASE_STORAGE_BUCKET,
messagingSenderId: FIREBASE_MESSAGING_SENDER_ID,
appId: FIREBASE_APP_ID,
measurementId: FIREBASE_MEASUREMENT_ID,
};
const app = initializeApp(firebaseConfig);
export default app;
export const auth = getAuth(app);
export const firestore = getFirestore(app);
if (process.env.NODE_ENV === "development") {
connectAuthEmulator(auth, "http://localhost:9099");
connectFirestoreEmulator(firestore, "localhost", 8080);
}
Do let me know if you need to see more files or need to know more details.
firebaser here
There was a problem in our JavaScript SDKs, where Firebase Installation Services used a version of IDB that doesn't support ESM outside of browser environments. The issue has been fixed in version 9.6.9 of the JavaScript SDK, so be sure to update to that.
I'm getting the same issue, looks like, it's breaking on "firebase": "^9.6.8", which was released a few days ago. Use "firebase": "9.6.7",
I've been getting the same issue, I've tried all the same things as you to no avail. I symbolicated the logs from firebase test lab and came up with this:
Stacktrace
Generally I have no idea how all of these libraries work together, but are you using typesense with firestore? I wonder if your stack trace calls out the same files, but I can't find any smoking gun here. I'll keep updating this thread if I find something. (I would have commented but I don't have the rep yet)
Update: Looks like my build just fixed itself somehow, even submitting builds from this weekend that would constantly crash. So truly I'm not sure what happened but it may be resolved
I had the same issue, my solution was to downgrade the Firebase version from 9.6.8 to 8.2.3.
Here is a reference that could be helpful.
https://github.com/expo/expo-cli/issues/3066
I had this same issue, and after trying multiple different firebase versions, this is the one that fixed the error for me:
npm install firebase#9.4.1 --save
Here's where I found this: Get Started with Cloud Firestore
The other fixes mentioned in this thread are definitely all valid (I have seen other forum posts suggesting the firebase downgrade but in my case it did not work.)
I thought it could be helpful for me to confirm what fixed the problem in my case. The problem arose from when one of my team members used npm instead of expo (which defaults to yarn) to install a dependency. This caused syncing issues between the yarn.lock and package-lock.json. This alone wouldn't have caused much of an issue because a simple yarn or yarn install <dependency> would have solved the issue. However, this dependency happened to require pre-existing dependencies which were of a different version then the ones "expected" by my version of expo. How this IDBIndex error was triggered is still a mystery to me, but in the end all I had to do was remove all my lock files and node_modules, perform an expo updateand finally do a yarn to reinstall all now-compatible packages.
If anyone stumbling across this answer can give a possible explanation as to why this fixed things, that would be much appreciated.
Here is what worked for me (using yarn):
deleted node_modules
deleted yarn.lock
downgraded to firebase "9.6.7" yarn add firebase#9.6.7
downloaded packages using yarn install
made sure all my imports are from the correct firebase library. I am using expo, and I had imported both firebase and react-native-firebase, which was causing trouble. I deleted react-native-firebase for now until I eject if needed.
Fixed my imports. Now you import firebase like this import firebase from "firebase/compat"
if you use firebase analytics, remove it
firebase version "firebase": "9.6.7"
import { initializeApp } from 'firebase/app';
import { getFirestore } from 'firebase/firestore';
// import { getAnalytics } from "firebase/analytics";
const firebaseConfig = {
apiKey: process.env.FIREBASE_APP_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.FIREBASE_APP_ID,
measurementId: process.env.FIREBASE_MEASUREMENT_ID,
};
export const app = initializeApp(firebaseConfig);
// export const analytics = getAnalytics(app);
export const firestore = getFirestore(app);
Had the same issue, I just downgraded firebase version and it worked.
you can use this code for downgrading:
npm install firebase#9.4.1 --save
This worked for Expo:
https://github.com/firebase/firebase-js-sdk/issues/6253#issuecomment-1123923581
// metro.config.js
const { getDefaultConfig } = require("#expo/metro-config");
const defaultConfig = getDefaultConfig(__dirname);
defaultConfig.resolver.assetExts.push("cjs");
module.exports = defaultConfig;

Firebase admin looking for a different default project than the one I'm currently working on my local environment

I'm building this cloud function in my local environment and I need to save something to Firestore:
Here's how I'm initializing the firebase-admin app:
myFunction.js
if (!adminHasInitialized) {
console.log("INITIALIZING ADMIN APP"); // THIS IS BEING LOGGED
admin.initializeApp({
credential: admin.credential.applicationDefault(),
});
adminHasInitialized = true;
}
And here's how I'm trying to update my Firestore:
await admin.firestore().collection("myCollection").doc("myDoc").update({
...
});
NOTE: I'm working on MY_PROJECT_1
And this is the error I'm getting:
details: 'No document to update: projects/MY_PROJECT_2/databases/(default)/documents/myCollection/myDoc',
PROBLEM
Somehow firebase-admin is looking inside another database for a different project MY_PROJECT_2 that I have.
When I run: firebase projects:list, this is what I get:
Project Display Name │ Project ID │ Resource Location ID
MY_PROJECT_1 │ MY_PROJECT_1 (current) │ us-central1
MY_PROJECT_2 │ MY_PROJECT_2 │ us-central1
So the current project is correct.
Also I have this file, which I set the default as MY_PROJECT_1
.firebaserc
{
"projects": {
"default": "MY_PROJECT_1"
}
}
I also tried to add the DB URL when I'm initializing the app, as:
admin.initializeApp({
credential: admin.credential.applicationDefault(),
databaseURL: "https://MY_PROJECT_1.firebaseio.com"
});
But I keep getting the same error.
NOTE: I'm running this function in my local environment using babel-node throught the following command:
npx babel-node functions/src/myFunction.js
QUESTION
How is firebase-admin getting a different default project than the one I'm currently working on?
UPDATE 1
I think that firebase-admin is getting the default configuration from the gcloud SDK that is installed in my PC.
From:
[C:\Users\USER\AppData\Roaming\gcloud\configurations\config_default]
config_default:
[core]
account = my#email.com
project = MY_PROJECT_2 // MAYBE IT IS COMING FROM HERE
UPDATE 2
So far, the only thing I've managed to make it work is with:
admin.initializeApp({
projectId: "MY_PROJECT_1",
databaseURL: "https://MY_PROJECT_1.firebaseio.com"
});
This gives me the correct project when I run this function locally.
Since version 1.0.0 of the Firebase SDK for Cloud Functions you don't need anymore to initialize with admin.initializeApp(functions.config().firebase);, see the doc here, which explains that:
firebase-admin is now initialized without any parameters within the
Cloud Functions runtime.
So please try with:
if (!adminHasInitialized) {
console.log("INITIALIZING ADMIN APP");
admin.initializeApp();
adminHasInitialized = true;
}

Error while initializing Service Account key

When I try to initialize my service account key like so:
const admin = require('firebase-admin');
const serviceAccount = require("./serviceAccountKey.json");
// Initialize the Firebase Storage admin constant
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: "<DATABASE-NAME>.appspot.com",
databaseURL: "https://<DATABASE-NAME>.firebaseio.com"
});
I get the following error Error parsing triggers: Cannot find module './serviceAccountKey.json'
My serviceAccountKey.json file is inside my project name folder.
Also my dependencies from Firebase are the following:
"dependencies": {
"firebase": "^6.5.0",
"firebase-admin": "8.4.0",
"firebase-functions": "^3.2.0"
},
My directory structure is the following:
-server
-idea
-bin
-functions
-node_modules
-public
-routes
-views
-.firebaserc
-.gitignore
- app.js
- firebase.json
- master
- package.json
- package-lock.json
- serviceAccountKey.json ===> ***
- server.iml
Why am I getting this error?
Note: I've done some research on this and my file path does conform with the node.js documentation on using the require method.
Put your serverAccountKey.json file in your "functions" folder. The entire contents of that gets packaged up and sent to Cloud Functions (unless you changed that default in firebase.json). Files that are outside that folder will not be available. Right now, it looks like the file is in "server".

Error with Firebase on Electron app: Failed to load gRPC

I'm building an Electron app, and in the renderer.js file, I'm using Firebase Admin to get Firestore data. However, whenever I run it, it returns this error in the logs..
Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: electron-v2.0-darwin-x64-unknown
Found: [node-v48-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
I tried to run "npm rebuild", but it still didn't fix it.
I also tried updating Firebase Admin and gRPC.
Here is the code from the renderer.js file...
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
const admin = require('firebase-admin');
var serviceAccount = require('./credentials.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://mytestapp.firebaseio.com"
});
var db = admin.firestore();
const settings = {
timestampsInSnapshots: true
};
db.settings(settings);
function LoadList() {
db.collection("Orders").get().then(function(Collection){
Collection.forEach(function(OrderDoc){
console.log(OrderDoc.id)
})
}).catch(function(err){
console.error(err);
});
}
document.querySelector('#ListSec').addEventListener('click', LoadOrderList)
Any ideas? I've been trying to solve this for hours, but can't seem to figure it out.
That error message indicates that gRPC was installed for Node, not for Electron. Electron has a different binary interface, so binary modules like gRPC need to be installed specifically for Electron. You can generally do this just by running npm rebuild --runtime=electron --target=2.0.0 (modified to match the version of Electron you want to use).
The original answer by #murgatroid99 was helpful at the time, and a postinstall command worked great up until electron v7, where the issue returned.
For anyone else who comes across this issue, I've found a better solution:
the electron-rebuild package
npm install electron-rebuild --save-dev
Run it using
npx electron-rebuild
Or, add it as a postinstall command
{
...
"scripts": {
"postinstall": "electron-rebuild"
},
...
}
Further information is in the official Electron Documentation

How to supply authentication to firebase-import?

I would like to import a json file into my Firebase database. I tried firebase-import as follows:
$ firebase-import --firebase_url https://mytest.firebaseio.com/ --json test.json
but I am getting a "Permission denied" error.
I know that firebase-import has --auth option, which says "Specify an auth token to use (e.g. your Firebase Secret)". How do I get an auth token or my Firebase Secret?
Looks to me like you need to create a service account (see https://firebase.google.com/docs/server/setup) and the provide the service account JSON to firebase-import using the --service_account command-line option.
Create New Project.
Click Add App
Add Firebase to your web app.
this code will show up
<script>
// Initialize Firebase
// TODO: Replace with your project's customized code snippet
var config = {
**apiKey: "<API_KEY>",**
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
storageBucket: "<BUCKET>.appspot.com",
};
firebase.initializeApp(config);
</script>
that is you API key then add -a API_KEY
so you will have
firebase-import --firebase_url https://test.firebaseio-demo.com --json test.json --merge -a API_KEY

Resources