firebase-functions: Error in emulated function: Provided authentication credentials for the app named "[DEFAULT]"
Version info
**firebase-functions:^0.6.2
**firebase-tools:3.10.0
**firebase-admin:~5.2.1
node: 6.11.2
Test case
Somehow a DEFAULT is stuck when I start a new project for firebase serve --only functions It seems like firebase functions is stuck with a reference from a previous project somewhere. Setting a blank new code project and a new firebase project I cannot get it to update the database.
This error keeps popping up:
error: FIREBASE WARNING: Provided authentication credentials for the app named "[DEFAULT]" are invalid.
However, on a fresh machine, it all works ok.
Steps to reproduce
Initialize a basic functions project (in a new firebase project)
index.js
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.helloWorld = functions.https.onRequest((request, response) => {
return response.send("Hello " + request.query.name || 'No one');
});
exports.helloWrite = functions.https.onRequest((request, response) => {
admin.database().ref("/test/x1").set({
hi: request.query.name || "there",
date: new Date().toISOString()
}, function (err) {
if (err) console.log(err);
return response.send("Hello " + request.query.name || 'No one');
});
});
Serve it
firebase serve --only functions
Test it
curl -X GET 'http://localhost:5000/live-test-49290/us-central1/helloWorld?name=Steve'
Hello Steve
All is good
Test the write
curl -X GET 'http://localhost:5000/live-test-49290/us-central1/helloWrite?name=Steve'
error: FIREBASE WARNING: Provided authentication credentials for the app named "[DEFAULT]" are invalid. This usually indicates your app was not initialized correctly. Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.
NOT so good here…
.firebaserc
{
"projects": {
"default": "live-test-49290"
}
}
When I try to get a config
firebase functions:config:get
{}
I have multiple firebase logins and multiple projects in each login. Have tried firebase logout and firebase login
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 29 (12 by maintainers)
@laurenzlong thank your helping with this. I can confirm I am on @3.13.1 and I am getting the exact same error.
@laurenzlong as @wuservices mentioned in an earlier comment, try removing env var
GOOGLE_APPLICATION_CREDENTIALS
if set. That at least solved the problem for me.@aminelaadhari That seems to be a different issue then, since this issue is about locally emulated functions. Can you file a separate issue, and include all the information asked for by the template, as well as my questions above?
Can you try running:
Then try
firebase experimental:functions:shell
again.Sorry about this! This was a bug in the CLI that was affecting deploys as well as emulation. Should have been fixed in v3.10.1 (https://github.com/firebase/firebase-tools/releases/tag/v3.10.1). Please reopen the issue if it’s still there after updating firebase-tools.