I wish to implement signInWithPhoneNumber() on the backend. That is, Get the phone number and recaptcha on the front, let the backend handle the request to firebase, send the confirmation code from the front with the confirmationResult to the backend and verify there.
signInWithPhoneNumber()
confirmationResult
How do I go about sending the recaptcha to my express backend? signInWithPhoneNumbers requires RecaptchaVerifier as a second argument, which returns a promise. I can't send it as is, is there a work around for this?
signInWithPhoneNumbers
RecaptchaVerifier
Firebase is a technology meant to be used as a backend and not behind another backend. The documentation of firebase clearly indicates that the javascript sdk is to be used for web front end (https://firebase.google.com/docs/web/setup).
Whereas express js is a backend. Given a design choice of abstracting firebase behind the api, I would suggest you revisit the design choice. As in mentioned in another comment this appears to be a XY problem (http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). The api you are trying to use is meant for a web based browser or a mobile frontend. You may end up with a hacky implementation in trying to go with the design choice or have to change the way you authenticate to use firebase Auth on frontend and pass a token after Auth to the backend. Have a look at these links
https://dev.to/emeka/securing-your-express-node-js-api-with-firebase-auth-4b5f https://fireship.io/snippets/express-middleware-auth-token-firebase/
There is another option of using a custom implementation of authentication backend to generate token and use that token to sign in to firebase. That would however beat the purpose of the firebase Auth. I would recommend it only if you already have a existing backend and are adding firebase for different features of firebase. Please consider this link if that matters to you.
https://firebase.google.com/docs/auth/web/custom-auth
1.4m articles
1.4m replys
5 comments
56.9k users