0

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?

stefan de boer
  • 389
  • 1
  • 8
  • 20
  • What's the problem? Are you just saying the URLs you're trying to click are supposed to do something? Could you edit the question to be more specific about what you're doing and expecting? – Doug Stevenson Feb 22 '20 at 02:02
  • @Doug Stevenson i edited my question a bit. I hope its a bit more specific for you now. – stefan de boer Feb 22 '20 at 02:11
  • There's really not enough information here to tell what you're trying to do. What are you expecting to happen from clicking on random URLs in debug output? If you're having problems deploying with the Firebase CLI, perhaps you should explain what's happening to Firebase support. https://support.google.com/firebase/contact/support – Doug Stevenson Feb 22 '20 at 02:24
  • @Doug Stevenson The reason im clicking those url's is to find out what is going wrong with the deploy. That is the only source of information i have about whats going wrong. – stefan de boer Feb 22 '20 at 02:29
  • Those are internal APIs used by the Firebase APIs, and they're there for diagnostics. You can't use them by loading them into your browser. If you're not getting any helpful error messages from the CLI output, you should contact Firebase support. – Doug Stevenson Feb 22 '20 at 02:31
  • @Doug Stevenson Thank you, i did not know that. I guess contacting them is my only hope then. – stefan de boer Feb 22 '20 at 02:34
  • Does this answer your question? [Why is this CORS authenticated Google Cloud Function returning a 403 when passing an id token from Firebase authentication?](https://stackoverflow.com/questions/58986011/why-is-this-cors-authenticated-google-cloud-function-returning-a-403-when-passin) and see https://cloud.google.com/functions/docs/securing/authenticating – zkohi Feb 22 '20 at 04:19
  • @DougStevenson I edited my question because i found some new information that might be useful. Maybe this is the problem? – stefan de boer Feb 22 '20 at 11:49
  • Try updating firebase-tools to latest version. "npm install -g firebase-tools" – Nibrass H Feb 25 '20 at 08:46

0 Answers0