Flutterfire: CLOUD FUNCTIONS

Created on 20 Sep 2019  路  9Comments  路  Source: FirebaseExtended/flutterfire

Describe the bug
Cloud function call thru flutter cloud package is failing. Getting response 'UNAUTHENTICATED'.
There is 'Invoke function' role attached to 'allAuthenticatedUsers' user group.
To Reproduce
I am using a following simple function

const functions = require('firebase-functions');
exports.hello = functions.https.onCall((data, context)=>{
 return{ "data":"Hello from Firebase!"};
});

Using flutter cloud_functions 0.4.1+1 package to make a function call like this.

try {
      print("----------------------");
      final HttpsCallable callable = CloudFunctions.instance.getHttpsCallable(
        functionName: 'hello',
      );
      HttpsCallableResult resp = await callable.call();
      print(resp.data);
    } on CloudFunctionsException catch (e) {
      print(e.message);
      print(e.details);
    } on Exception catch (e) {
      print(e);
    }

Only 'allAuthenticatedUsers' members have 'Cloud Function Invoker' role.
If I add 'allUsers' group to 'Cloud Function Invoker' then error disappears and data is returned back. User is logging in using flutter firebase auth package in the application.
My assumption is that client library passes the necessary logged in user token. What I am missing? Do we need to do something special to pass auth credentials to function?

crowd functions bug

All 9 comments

i got the same problem. When i tried to call an http function from firebase, the error message shows "UNAUTHENTICATED".
I tried to sign in with email and password, but the error still exist.

I'm getting the same with 0.4.2+3. The cloud function isn't even called. Though the user is logged in.

Same issue.

same Issue

I have the same issue on 0.4.2+3. Tested on both iOS and Android.

I figured out that I have to go to google cloud console, set the permission for this function to all users. It is a callable function. Some other functions are assigned to all users by default but the latest one needed to do it manually. And it should be AllUsers not AllAuthenticatedUsers.. we should watch our security within the function.. Either I don鈥檛 get it completely or something weird is happening

Thanks @bdairy, this will be great for testing my functions but I don't believe it is very secure so I have created a support ticket with Firebase to clear things up.

Quick note on this one; the docs also state:

Caution: New HTTP and HTTP callable functions deployed with any Firebase CLI lower than version 7.7.0 are private by default and throw HTTP 403 errors when invoked. Either explicitly make these functions public, or update your Firebase CLI before you deploy any new functions.

Hey, even I am facing the same issue even after updating the firebase cli and deploy, is there any update on this?

Was this page helpful?
0 / 5 - 0 ratings