1

At first, I thought the advantage was being able to call HttpsCallables, but now I know that you can call these with some special format and parameters from Postman (and it is also possible using UnityWebRequest, and if not, could just change them from onCall to onRequest).

Then, I thought that it might include some special authorization info from the client to the server. But context.auth (from https.onCall(data, context)) appears to be undefined. Plus, I can still call the functions from Postman.

Important note: I am not registering users, so I don't need Firebase Auth specifically. But I imagined Firebase added something to verify that the function call was coming from an authorized client (e.g. the app).

I am still using the Functions SDK, but I am wondering, what are the advantages of using this SDK for Unity, when UnityWebRequest exists? Why should I have an package when I can perform the same call using a UnityWebRequest? Am I missing something too obvious?


Additional information of how I am using Firebase Functions:

  • I have a level editor where people can contribute with levels. I use a function to add these levels to Firestore.
  • When these levels are created, a database trigger runs and checks if that level was already created.
  • Getting levels from the database to replay.
  • Finally, in the future I plan to create a voting system to help me curate the levels.

1 Answer 1

1

Auth state should be passed along from the Firebase Functions client to your callable Cloud Functions automatically. If that is not the case, I'd report that as a bug.

But outside of that: there's indeed nothing the SDK does that you can't also do yourself. Using it is a matter of choosing between greater convenience and more fine grained control.

If you use the Firebase-provided SDK, you won't have to build anything yourself. But on the other hand, if you build your own client-side implementation of the wire protocols, you have full control over what you do, and don't, implement.

3
  • nice, thanks for that confirmation. To clarify: do I need the Auth SDK for the Auth state to be passed along? Or the Functions SDK itself handles this? And while we are it, could you point me where to report the bug? Feb 26, 2020 at 18:34
  • Yes, you'll have to pass the ID token along yourself, which you'd get from the Auth client. I think the answer to "why would I use the Firebase SDK for this?" is now clearly in the "so that you don't have to figure that out" camp. :) Feb 26, 2020 at 18:47
  • 2
    To report an issue, you can use the form here: firebase.google.com/support/troubleshooter/report . If you want some user id to pass along, you can use Firebase Authentication to create an anonymous user ( firebase.google.com/docs/auth/unity/anonymous-auth ). You will probably want a privacy policy at this point since you're storing some kind of data, but it can otherwise be an invisible way to accomplish what you want with Callable functions (and you'll want to make sure you don't call auth.SignInAnonymouslyAsync() every run, check auth.CurrentUser first). Feb 26, 2020 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.