Why don't I see the Firebase Web App API key? - firebase

Another app to add click > web click > Add a web app Firebase.
My situation
<script src="https://www.gstatic.com/firebasejs/3.4.1/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "",
authDomain: "********.firebaseapp.com",
databaseURL: "https://**********.firebaseio.com",
storageBucket: "********.appspot.com",
messagingSenderId: "*********"
};
firebase.initializeApp(config);
</script>

Go to Firebase Console. Select your app then you have your separated platform (ios, android) if ever you created two platforms already, if not, Click the additional settings from the upper right of the app, then click Manage. see image below:

Related

How can I initialize the Firebase Admin SDK in spring-boot application using kotlin

I would like to get data from Firebase. I found some tutorials, but all is using Google Credential ServiceAccount to initialize firebase app. this's is tutorial that i found :
https://medium.com/techwasti/spring-boot-firebase-crud-b0afab27b26e , and else tutorial i found, almost like that too, is using ServiceAccount.
But the problem is i cannot get the ServiceAccount from this firebase because it's from third party. that's mean the owner of firebase don't want to give ServiceAccount.json to me, but they give me firebase config to me, like this :
const firebaseConfig = {
apiKey: "apkey",
authDomain: authdomain",
databaseURL: "databaseurl",
projectId: "projectid",
storageBucket: "storragebucket",
messagingSenderId: "messagesenderid",
appId: "appid",
measurementId: "measurementid"
};
So, how can i initialize this firebase using kotlin in my java springboot aplication?
i had try to find the solution, but not found anything,
I would be glad for any help.
If you want to initialize the Firebase Admin SDK, you will need a service account. There are no alternatives for this.
The config for the front end web app that you're showing here will not work at all. That config is only used for frontend apps that are acting as clients on behalf of the end user.

Firebase Analytics not working with web SDK installed on Expo app

I have firebase realtime database up and running with my expo app. I'm using the web SDL with the following code in my index.js file.
import * as firebase from 'firebase'
const firebaseConfig = {
apiKey: "XXXXXXXXXX",
authDomain: "XXXXXXXXXX",
databaseURL: "XXXXXXXXXX",
projectId: "XXXXXXXXXX",
storageBucket: "XXXXXXXXXX",
messagingSenderId: "XXXXXXXXXX",
}
firebase.initializeApp(firebaseConfig)
However no information is appearing in the analytics section of my firebase console dashboard. It says,
'Your Analytics data will appear here soon
We're ready to start collecting your Analytics data. Integrate the SDK, and within 24 hours you'll see your first reports.'
But have I not already integrated the SDK in my app with the code above? What am I missing here, is there some other link I need to make between the app and the dashboard?

Where can I find my Firebase apiKey and authDomain

Where can I find my Firebase apiKey and authDomain?
I'm setting up my environment to connect to my database.
export const environment = {
production: false,
firebase: {
apiKey: '...',
authDomain: '...',
databaseURL: 'https://******-project.firebaseio.com',
projectId: '*******-project',
}
};
But can't find the apiKey and authDomain inside the firebase console.
The easiest way to find these is to:
go to the Project overview page in the Firebase console
click the + in the top bar
click </> button to add a web app
You'll get a pop up with the values you need.
The easiest way to find these properties without having to create a new app is to go to your project in the Firebase Console.
Next, click the gear icon beside the Project Overview in the sidebar to the left at the top and click on project settings.
Under the general tab, which is what should open up by default, scroll down a bit til you get to the your apps section. Inside that area, you will find the Firebase SDK Snippet heading.
Under that, you'll have three checkboxes. Go for the Config checkbox, and you will see a JS object declaration, with all the information you'd need about your app to connect to the database.
Your Firebase SDK Config
If you don't want to create a web app, and the other non-create solution above didnt work for you like it didnt work for me, here's a cheatsheet:
firebaseConfig = {
apiKey: (this one's easy, it's in the 'General' section in your project settings page, aka the Gear icon button),
authDomain: "{project_id}.firebaseapp.com", (without brackets)
databaseURL: "https://{project_id}.firebaseio.com",
projectId: (again, found in 'General' section in Project Settings),
storageBucket: "{project_id}.appspot.com",
messagingSenderId: (found in 'Cloud Messaging' section in Project Settings)
Go to console then open your project
Click Authentication
Look at the upper right side then click the Web setup
Then copy&paste
You can find it in one of the following ways:
Click Authentication and at the upper right side in that page, click Web setup.
Otherwise Go to your project overview, click on '+ Add app' button, which you can find next to your project name. After that, select 'web app' or < / > button. Give your web app name and click continue. Then a pop-up appears with your app details.
<script src="https://www.gstatic.com/firebasejs/8.8.0/firebase-app.js"></script>
<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "XXX-XXXX-XXXX",
authDomain: "xyz.firebaseapp.com", // as follows your app uri xyz.firebaseapp.com/__/auth/handler
projectId: "xyz",
storageBucket: "xyz.appspot.com",
messagingSenderId: "XXXXXXXX",
appId: "1:XXX:web:XXX",
measurementId: "G-XXX"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
<script src="https://www.gstatic.com/firebasejs/8.8.0/firebase-analytics.js"></script>

Using Same Firebase App With Web and Mobile App

So say I am building a web app using React and also a mobile app that allows users to take a photo using React Native. I want to allow users to use the same login credentials when signing into the web app and also the mobile app. Can I use the same Firebase info for both the web app and mobile app? Like just include the snippet below in both code bases to allow them to both use the same database, storage, etc?
<script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
<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",
messagingSenderId: "<SENDER_ID>",
};
firebase.initializeApp(config);
</script>
A single Firebase project can be used as the back-end for many (iOS, Web and Android) apps. All these apps will be talking to the same back-end services.
So if you create two web applications on a single Firebase project, those apps will be using the same database, the same list of users, the same stored files, etc. If you then add an iOS or Android app, that will also be accessing the same users/database/files.

How i version firebase code without credentials?

When you sign up to firebase they tell you to place this snippet in your code:
// Initialize Firebase
var config = {
apiKey: "your api key",
authDomain: "domain",
databaseURL: "database url",
storageBucket: "storage bucket",
messagingSenderId: "messaging sender id"
};
firebase.initializeApp(config);
Turns out i want to version it publicly on Github. Is there a way i can use some kind of environment variable or should i just don't version a credentials.js script.
All the information in that snippet is meant to be publicly shared with the users of your web app.
These are not secrets or credentials, but they're identifiers that allow the app code to find the Firebase project on Google's servers.
That said: many teams do not want to check it in to version control system, but instead force each developer to use their own Firebase project for development/testing.

Resources