Issue calling Cloud Function (through local emulator) from SwiftUI App

48 views
Skip to first unread message

evan

unread,
Jan 23, 2021, 10:57:44 PM1/23/21
to Firebase Google Group
I'm currently running the Auth, Firestore, and Functions emulators and then start up and run fine. I also connected my SwiftUI app to the emulators through (in my App file init() method)

        FirebaseApp.configure()

        #if DEBUG

        Auth.auth().useEmulator(withHost: "localhost", port: 9099)

        Functions.functions(region: "us-east4").useEmulator(withHost: "localhost", port: 5001)

        let settings = Firestore.firestore().settings

        settings.host = "localhost:8080"

        settings.isPersistenceEnabled = false

        settings.isSSLEnabled = false

        Firestore.firestore().settings = settings

        #endif

The Auth and Firestore emulators work fine. The local onCreate trigger cloud function also runs when the User is created. When I call my search function (callable function, down below), I get an "Unauthenticated" error. The "result" variable was nil

When I connected to GCP Cloud Functions, everything worked.


private lazy var functions = Functions.functions(region: "us-east4")

self.functions.httpsCallable("search").call(["query": searchText]) { (result, error) in ........


Not sure if anyone else has seen this issue but any advice would be greatly appreciated!


Sam Stern

unread,
Jan 26, 2021, 7:12:08 AM1/26/21
to Firebase Google Group
Hi Evan,

Since you're getting Unauthenticated it sounds like the request is hitting the emulator successfully but the Auth token is being rejected. Could you file a new issue here and include all of the emulator debug logs so we can see what's going on?

- Sam

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/3f9a2a65-abf1-4adf-950b-e74f2809a58an%40googlegroups.com.

evan

unread,
Jan 26, 2021, 10:03:43 AM1/26/21
to Firebase Google Group
Yeah definitely. I assumed it wasn't connected to the emulator because there were no logs in the shell where I ran the emulator. When the onCreated trigger is triggered, it logs that it was triggered but when the Callable is suppose to be triggered, there is no message/log. Is that suppose to be the case?

Sam Stern

unread,
Jan 26, 2021, 10:06:36 AM1/26/21
to Firebase Google Group
No there should be logs ... can you check your production logs and see if you're actually hitting there?  Also where is "self.functions" defined? 

- Sam

Evan Anger

unread,
Mar 11, 2021, 5:46:06 AM3/11/21
to Firebase Google Group
Super weird having the exact same problem.

SwiftUI app with Auth
Function works via emulator
Also my name is Evan.

When I deploy I get a quick unauthenticated error.  No logs into Firebase functions.
Makes me think the function deployed incorrectly.

Was there any closure on this issue?
Reply all
Reply to author
Forward
0 new messages