functions-framework-dart icon indicating copy to clipboard operation
functions-framework-dart copied to clipboard

Firebase (functions) SDK support

Open xinoxapps opened this issue 4 years ago • 4 comments

Obvious feature request.

Hope to see it as soon as possible.

xinoxapps avatar Jan 11 '21 16:01 xinoxapps

@xinoxapps – do you mean supporting Firebase functions?

kevmoo avatar Feb 13 '21 05:02 kevmoo

I'd understand this issue like this, that all the features of the Firebase API should be accessible from the running Cloud Run container. In particular, I would want to access data from Cloud Firestore or the Realtime Database.

I guess all of this could be done via the firebase package on "pub.dev".

But how would the authentication work from the container towards Firebase? Would the client go through the authentication process like explained in this tutorial and then provide an access token to the Cloud Run container which then passes it through for the authentication towards Firebase?

https://cloud.google.com/run/docs/tutorials/identity-platform

jmewes avatar Feb 13 '21 19:02 jmewes

Need firestore and firebase auth examples to be included with this amazing framework so I can get my flutter apps to talk to firestore in a more controlled manner. (use case: flutter web app connects to firebase admin SDK to manage data that users have pushed into the firestore using their mobile apps).

mrgithub avatar Mar 12 '21 00:03 mrgithub

Here's how I got it to work...

  1. Generate a service-account.json from the GCP IAM console and include it in your build secrets
  2. Attach that file to your Dockerfile that gets generated and uploaded
  3. Using googleapis and googleapis_auth you can create a clientViaServiceAccount
     _client = await clientViaServiceAccount(
        ServiceAccountCredentials.fromJson(
          json.decode(
            File(pathToServiceAccount).readAsStringSync(),
          ),
        ),
        scopes,
      );
    
  4. Now you can use the FirestoreApi class, or just directly call the Firebase REST URLs, using the now authenticated _client to do what you need.

jpeiffer avatar Apr 19 '22 20:04 jpeiffer