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

HTTPS Callable cloud-functions

Open yamauchieduardo opened this issue 4 years ago • 3 comments

Awesome project! I'm really impress, I'm looking something like this around 3 years. I'll try to use this package in a large production project. But I'm have some questions:

  • This project will implement callable firebase functions in the future?
  • Have any roadmap?

Thanks for the attention.

yamauchieduardo avatar May 06 '21 15:05 yamauchieduardo

Hey! I'm not the maintainer, just someone trying to solve a similar problem. I agree this would be awesome to have, but for now I've found some nice workarounds you could try:

As I understand, the advantage to using callable functions is that it validates the auth token from Firebase auth and parses your json payload into an object.

  • For the first problem, you can validate the tokens pretty easily; you just have to include the token in a header when you make a request (you can get the token from all the client libraries) and validate it on the back end. In fact, I just made a small package for validating the tokens (https://pub.dev/packages/validate_firebase_auth). It's still very new but should work for validating the JWTs from Firebase Auth.
  • For the second, the Functions Framework can already serialize and deserialize dart objects to json as long as you include a .toJson in your response object and a .fromJson in your request object. Example here
  • ~The only issue is if you write a json serialized function as of now, you can't get to the headers so you'll probably have to do a standard http function for now if you need both functionalities.~

EDIT July 2022: This isn't true anymore, you can use json serialized functions and headers at the same time :) See this answer for more details

mtwichel avatar May 28 '21 02:05 mtwichel

Hey there @mtwichel do you happen to remember where that example was?

novvia-dev avatar Jul 12 '22 21:07 novvia-dev

Hey there @mtwichel do you happen to remember where that example was?

Weird that my link didn't work on my comment originally. Here it is: https://github.com/GoogleCloudPlatform/functions-framework-dart/tree/main/examples/json

mtwichel avatar Jul 12 '22 22:07 mtwichel