7

I have downloaded the zip of Firebase real-time database node.js sample and navigate to the database section

https://github.com/firebase/quickstart-nodejs/tree/master/database

And I located to the line 35 which has the following code

var serviceAccount = require('path/to/serviceAccountKey.json');

But I was wondering where is/what is the serviceAccountKey.json?

Andrew
  • 83
  • 1
  • 1
  • 10

4 Answers4

14
  1. require('path/to/serviceAccountKey.json') means - call this file to be used in the file you are calling it

  2. serviceAccountKey.json is a file that you have to generate

  3. If you look at this page 'Add Firebase To Your App' https://firebase.google.com/docs/ios/setup under 'Add Firebase to your app' - it says Navigate to the Service Accounts and generate a new private key, doing this will generate what will be your 'serviceAccountKey.json' file after you rename it

  4. place that file in the directory of your choosing local to your cloud code directory, have a look at this comment https://stackoverflow.com/a/42634321/2472466 for more insight into step 4

Yashwardhan Pauranik
  • 5,370
  • 5
  • 42
  • 65
t.ios
  • 1,024
  • 12
  • 18
8

How to download your serviceAccountKey.json file

  1. Open Your firebase project
  2. On the navigation drawer, select the project overview
  3. Then select "Project settings"
  4. On the new page, Select Service Accounts
  5. Download file and store in a secured place.

Note: Do not commit this file to git or share it with unauthorized users.

C Williams
  • 850
  • 12
  • 19
8

Go to settings -> Service Account -> Generate New private key

That will download the required Json

supersabbath
  • 364
  • 3
  • 8
6

It's a JSON file generated in the Firebase Console (see Add Firebase to your App) containing credentials about your corresponding Service Account.

AL.
  • 36,815
  • 10
  • 142
  • 281