I am deploying a Node.js/Express backend application on Google Cloud Run. This service uses the Firebase Admin SDK (firebase-admin) to initiate phone number verification server-side within a POST endpoint (/signup). When attempting to call admin.auth().signInWithPhoneNumber(), I consistently encounter a TypeError: admin.auth(...).signInWithPhoneNumber is not a function.
Setup:
Error:
The specific error received in the Cloud Run logs is:
Error initiating phone verification: TypeError: admin.auth(...).signInWithPhoneNumber is not a function at signUpUser (/app/app/signup.js:94:49) // Line and column number from my latest logs
Debugging Steps Taken:
I have performed extensive troubleshooting to try and resolve this, ruling out common issues:
Critical Findings from Logs:
The most surprising result came from the detailed logging (Step 7). The logs show:
admin object: object authInstance object type: object Methods available on authInstance: --- End of authInstance methods ---
This indicates that admin is a valid object, and admin.auth() returns an object (authInstance), but this authInstance object contains no callable methods, including signInWithPhoneNumber.
Expected Behavior:
I expect that after calling admin.auth(), the returned object (authInstance) should be a Firebase Auth instance with methods like signInWithPhoneNumber, createUser, getUser, etc., available for server-side use.
Request for Help:
I am seeking assistance to understand why the object returned by admin.auth() in my Cloud Run environment appears to be empty of methods, leading to this TypeError. Given that the code seems correct, IAM roles are set, and the Firebase provider is enabled, is there a known compatibility issue, a specific configuration required for server-side phone auth initiation in Cloud Run with the Admin SDK, or a potential platform-level problem?
Any insights or suggestions on how to further diagnose or resolve this would be greatly appreciated.
Hi @famous_adequate,
Welcome to the Google Cloud Community!
Thanks for sharing your stack info and the highly detailed debugging steps you did. It really helps that you also included the logs and error messages.
According to the Firebase Authentication API reference for JavaScript, the method signInWithPhoneNumber()
does not work in a Node.js environment or with Auth instances created with a FirebaseServerApp. If it’s more feasible, consider implementing other Firebase Authentication methods for your use case or deploy in a different environment.
For now, I recommend creating a Firebase feature request to help with visibility within our engineering team. Do note that there isn’t a specific timeframe for issue resolution. Instead, we wait for a feature to have a handful of stars and, hopefully, comments from several users about how the feature would be useful. You may also open a new issue on the Firebase Admin Node.js SDK GitHub with the details of your use case.
Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.