Replies: 16 comments
-
After spending some more time on this I would like to clarify what was either my misunderstanding or an ambiguity in the docs (maybe both):
This is noting that "Firebase callable functions aren't your ordinary RESTful API" because they have a very precise protocol that must be followed. This reinforces my thought that this would be a good addition to this library, since the protocol is very specific to Firebase and won't be covered by any generic cURL wrappers. |
Beta Was this translation helpful? Give feedback.
-
I have anonymous callable functions working with a simple cURL request, setting only the headers specified in the protocol:
Note that lots of clients will magic set headers for you, but I had to specify them because it was always adding When I add in the authenticated user token (
I assume I'm using the wrong token or something... it's what I received back from FirebaseUI after a successful login. |
Beta Was this translation helpful? Give feedback.
-
As you‘re already at it ^^, how did you create the client? If you use I haven‘t checked yet, but perhaps there‘s an additional OAuth2 scope needed to invoke cloud functions. That would be a good test to see if a cloud functions must be invoked by a user explicitly or if the un“identified“ general service account is perhaps enough (I sincerely hope it does) |
Beta Was this translation helpful? Give feedback.
-
If it doesn't work, another possibility could be to generate an ID Token for a user like in firebase-php/tests/Integration/AuthTest.php Lines 145 to 148 in 568a9a7 |
Beta Was this translation helpful? Give feedback.
-
Yes I think you are right that I am using the wrong token. I'm playing with this right now to get it from the frontend but then I will try your version as well:
|
Beta Was this translation helpful? Give feedback.
-
I was able to invoke the callable without any credentials at all, actually! It ran fine, I saw in the logs. The issue is that many of the callable functions use EDIT: I should add that this behavior is more than just a whimsical developer choice, but matches the default SDK behavior for mobile since they will always include the current user token for callable functions. |
Beta Was this translation helpful? Give feedback.
-
You can specify custom claims when generating the custom token with the SDK, do they perhaps get passed to the Another possibility, based on the code that you presented, and if I'm not misunderstanding/forgetting something, would be to send the ID token from |
Beta Was this translation helpful? Give feedback.
-
That works! It's definitely a token type issue - not sure what FirebaseUI-Auth is returning in The actual code is a mess but here's an example of pretty much what I did:
|
Beta Was this translation helpful? Give feedback.
-
Great work! That's something I could definitely work with! Is the whole URL something that a developer would have to provide, or can it be somehow derived from some other information? What I'm meaning is... would you see more |
Beta Was this translation helpful? Give feedback.
-
As far as I know the cloud function subdomain will always match the Firebase project, like you said, so theoretically you could execute a cloud function call from the factory by simply passing it the name of the function and the data. |
Beta Was this translation helpful? Give feedback.
-
I was wondering because of the |
Beta Was this translation helpful? Give feedback.
-
I'm afraid my Firebase knowledge is limited that one project, with a test and production instance, so I can't really say! |
Beta Was this translation helpful? Give feedback.
-
I will start with the new component as soon as I have released #360. looking forward to doing so 🥳 |
Beta Was this translation helpful? Give feedback.
-
Splendid! Let me know how I can help. |
Beta Was this translation helpful? Give feedback.
-
Quick heads-up: I’m on it, but I’m going back and forth on how elaborate/configurable I want the implementation to be, so it might still take a while 😅 |
Beta Was this translation helpful? Give feedback.
-
That’s great! No worries on the timing. My implementation is working great. I thought I’d shared it (Discord maybe?) but here it is just in case: https://github.com/tattersoftware/codeigniter4-firebase/blob/develop/src/Components/Caller.php Feel free to borrow without attribution as ultimately I will be using the version from this library and not maintaining my own. |
Beta Was this translation helpful? Give feedback.
-
Callable Functions add significant functionality to a Firebase project, relieving the developer from handling multiple services simultaneously. There appear to be two variants of Callable Functions: "HTTPS callable functions" and "HTTP functions" (this goes beyond simply the protocol used, see https://firebase.google.com/docs/functions/callable). The former (as far as I can tell) requires one of Google's SDKs:
But the latter can be implemented by following their protocol specification: https://firebase.google.com/docs/functions/callable-reference
I think this would be a great addition to
firebase-php
to allow native Cloud Function calls from the backend. See also #284Beta Was this translation helpful? Give feedback.
All reactions