41

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.

AngularM
  • 15,982
  • 28
  • 94
  • 169

7 Answers7

53

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

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • 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 '18 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). – Frank van Puffelen Sep 25 '18 at 16:51
  • 1
    This answer seems to be up to date, see the answer below [here](https://stackoverflow.com/a/58374047/6952495) for more up to date answer – RyanQuey May 05 '20 at 06:36
42

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

39

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)
Adam Michalak
  • 155
  • 1
  • 8
Jim
  • 1,988
  • 6
  • 34
  • 68
  • 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 '21 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 '21 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 '21 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.
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>
  • 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](/help/how-to-answer). – Community Jan 28 '22 at 00:30
0
  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

Arsalan Ahmad
  • 111
  • 1
  • 4