I am currently trying to deploy my Cloud Functions to Firebase with firebase deploy --only functions
but this does not seem to work, it never finishes the deploy. I tried debugging the deploy with the command firebase deploy --only functions --debug
, this prints out all the requests with the url's that lead to the error messages. Whenever i click one of the url's of the requests it gives me this error:
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"status": "PERMISSION_DENIED"
}
}
Some of the other url's give me this error:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
I can't really find anything useful online on how to fix this either. The articles that i did find did not help me though.
This is my index.js
file where my Cloud Functions are:
const functions = require('firebase-functions');
const {firestore, auth} = require('./src/admin');
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
This is my admin.js
file where i define the serviceAccountKey
and such:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const serviceAccount = require('../serviceAccountKey.json');
const app = admin.apps.length
? admin.app()
: admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: functions.config().database.url || process.env.FIREBASE_CONFIG.databaseURL, // default firebase var
storageBucket: functions.config().storage.bucket || process.env.FIREBASE_CONFIG.storageBucket // default firebase var
});
module.exports = {
app,
firestore: app.firestore(),
db: app.database(),
storage: app.storage(),
auth: app.auth()
};
I have used this exact code before on another project so i assume its a Firebase problem and not my code. In the end i expect my Cloud Functions to be deployed by calling the firebase deploy --only functions
command without any authentication errors.
Can someone please tell me what i am doing wrong here?
UPDATE 22-2-2020 12:44 PM: I tried reinstalling and reconfiguring the firebase-tools
. After doing that and running the command again it gave me this error:
There was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this
issue persists, please contact support.
! functions: Upload Error: HTTP Error: 503, The service is currently unavailable.
Error: HTTP Error: 503, The service is currently unavailable.
The URL leads me to the page where you can setup your App Engine. Because i already set that up it says 'Your App Engine application has been created'. However whenever i click Get Started
button again, i have to create a billing account to proceed. This is keeping me from deploying my Cloud Functions. Is there a way to use Cloud Functions with a billing account?