pulyaevskiy / firebase-functions-interop

Firebase Functions Interop Library for Dart.
BSD 3-Clause "New" or "Revised" License
191 stars 52 forks source link

Cloud Functions Plugin/Firebase Functions Interop Issue #38

Closed kostaa closed 5 years ago

kostaa commented 5 years ago

I have finally wired it all up using the Cloud Functions Plugin on my Flutter client to call the function but now getting a CloudFunctionsException/Response is missing data field on the client after the call returns.

I/flutter ( 6077): throwing firebase functions exception I/flutter ( 6077): Firebase exception: Instance of 'CloudFunctionsException' I/flutter ( 6077): code: INTERNAL I/flutter ( 6077): message: Response is missing data field. I/flutter ( 6077): details: null

I have tried this with a simple 'Hello world' function as well (which returns a correct response in the browser) and getting the same issue. Just wondering if I need to construct the response differently for the client plugin be able to consume it.

Regards, Adam

pulyaevskiy commented 5 years ago

Are you trying to use Flutter cloud_functions plugin to invoke regular https.onRequest() function, because that's what it looks like from this error.

You can only invoke https.onCall() functions with the Flutter plugin. The benefit of onCall functions is that they abstract all authentication details, so that once you've authenticated with Firebase on your Flutter app you can simply send requests to onCall functions without needing to handle authentication yourself (the context argument of onCall function holds information about authenticated user).

If you created regular https.onRequest function you can simply invoke it using regular HTTP client.

Hope this helps.

kostaa commented 5 years ago

Got it. Many thanks.