47

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.

7 Answers 7

59

The easiest way to find these is to:

  1. go to the Project overview page in the Firebase console
  2. click the + in the top bar
  3. click </> button to add a web app

You'll get a pop up with the values you need.

enter image description here

3
  • 1
    Hi @Frank I've already made the project that has a database. I just don't know where to look for the apiKey and AuthDomain
    – AngularM
    Sep 25, 2018 at 14:55
  • 1
    If you follow my steps, it won't create a new app/project/database, but you can copy the values from that pop up: they're the first two values in there (starting with AIzaSy... and stack in my screenshot). Sep 25, 2018 at 16:51
  • 1
    This answer seems to be up to date, see the answer below here for more up to date answer
    – RyanQuey
    May 5, 2020 at 6:36
45

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

enter image description here

3
  • 2
    This is the most up to date answer
    – RyanQuey
    May 5, 2020 at 6:36
  • What does it mean if everything else in the config is present but there is no databaseURL?
    – Dal
    Jul 12, 2021 at 16:17
  • 1
    I don’t think this is how it works in the new firebase console?
    – onexf
    Feb 17, 2023 at 10:11
41

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)
3
  • My config doesn't show a databaseURL. It isn't even a key in the config object, can I still use this cheatsheet or is there a reason it doesn't exist?
    – Dal
    Jul 12, 2021 at 16:19
  • if youre saying the firebase console doesnt show you your databaseURL anywhere in the project settings, then you should be talking to firebase support, but im guessing thats not the case
    – Jim
    Jul 12, 2021 at 18:36
  • I think I'm learning that you don't need a databaseURL for firestore which is all I'm trying to use now, I never set up realtime database so I guess that is why it isn't there. Very new to firebase though
    – Dal
    Jul 14, 2021 at 23:22
2

Go to console then open your project
Click Authentication Look at the upper right side then click the Web setup
Then copy&paste IMG

1

You can find it in one of the following ways:

  1. Click Authentication and at the upper right side in that page, click Web setup.
  2. 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.
1
  1. Go to the firebase console and select your project.
  2. Select the Authentication.
  3. Go to the Setting tab.
  4. Inside Authorized domains you can find your authDomain.

Check the below picture for more details. Your Project > Authentication > Settings > Authorized domains

0
<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>
1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jan 28, 2022 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.