hidjou / classsed-react-firebase-functions

327 stars 180 forks source link

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. #13

Closed HeyAshh closed 4 years ago

HeyAshh commented 4 years ago

Getting this error in terminal when trying to send this code in postman

{
    "body": "New scream",
    "userHandle": "new"
}

g1 Any ideas?

HeyAshh commented 4 years ago

This happens 25 minutes into the video btw

bembit commented 4 years ago

Hi. Go to your Firebase dashboard / Settings / Service Account. At the bottom, select the Node JS Firebase Admin SDK, click on Generate Private Key. It should download a JSON for you. Rename it to something more convenient like "db.json", pase it in your /functions folder next to your index.js and insert the below into your index.js.

Database URL is in your firebase config file.

This should solve it.

const serviceAccount = require("./db.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://YOURDATABASENAME-NUMBER.firebaseio.com"
});
HeyAshh commented 4 years ago

Been a while, but I think that solved it for me! Thanks!