'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.
Solution 1:[1]
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.
Solution 2:[2]
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.
Solution 3:[3]
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)
Solution 4:[4]
Go to console then open your project
Click Authentication
Look at the upper right side then click the Web setup
Then copy&paste

Solution 5:[5]
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.
Solution 6:[6]
<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>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Frank van Puffelen |
| Solution 2 | |
| Solution 3 | Adam Michalak |
| Solution 4 | Dodong Advices |
| Solution 5 | PunithMatli |
| Solution 6 | ALIREAZ |


