Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Functions for Firebase - Getting Network error even though I'm making outbound http request for firebase-admin functionality

I have a functions file where all I'm currently trying to do is access the Firebase auth() functionality to check if a user exists, based on email, and then get their uid.

I have an Angular 2 app where I run an http request to call that function, but any time I try to run it, I get this error:

Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions

Here is my code:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

/**
 *  Function to get a user by email
 */
exports.getUserByEmail = functions.https.onRequest((req, res) => {
  console.log('req', req);
  return admin.auth().getUserByEmail(req.query.email);
});

Is this type of thing not allows on the Spark plan? I'm still in development of my app and this is the only thing I need working right now and I'd rather not have to start paying right away just to use this tiny feature. Is there anything I can do?

Thanks in advance!

like image 267
Stevie Star Avatar asked Apr 06 '17 02:04

Stevie Star


1 Answers

That warning message appears for all functions when executing on the Spark plan. It's just a warning - you can ignore it if you're not doing any outbound networking on your own.

We're looking into getting that message changed or removed so that it's less confusing.

The admin SDK should work fine. However, your function doesn't return a response properly, so it won't appear to do anything. HTTP triggers (please read those docs) must send a response to the client to terminate normally. They don't return promises like the other types of functions.

like image 62
Doug Stevenson Avatar answered Sep 24 '22 04:09

Doug Stevenson