Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using recaptcha with Firebase

Surprisingly-even more when both are Google products-there is no information that I can find on how to integrate Recaptcha with Firebase. Is it even possible? If not, what can I use to validate humans on a Firebase app that has no auth?

like image 624
Sergi Mansilla Avatar asked Dec 03 '16 19:12

Sergi Mansilla


People also ask

Can Firebase be used for authentication?

In the present era, user authentication is one of the most important requirements for Android apps. It is essential to authenticate users, and it is much harder if we have to write all this code on our own. This is done very easily with the help of Firebase.

Can we send OTP using Firebase?

You can use Firebase Authentication to sign in a user by sending an SMS message to the user's phone. The user signs in using a one-time code contained in the SMS message.

Can I run reCAPTCHA v2 and v3 on the same page?

Can I run reCAPTCHA v2 and v3 on the same page? To do this, load the v3 site key as documented, and then explicitly render v2 using grecaptcha.render.


1 Answers

This is a pretty old post, but here's the answer for fellow Google searchers like me. It's now built-in, and super easy to set up:

window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha', {   'callback': (response) => {     // reCAPTCHA solved, allow signInWithPhoneNumber.     // ...   },   'expired-callback': () => {     // Response expired. Ask user to solve reCAPTCHA again.     // ...   } }) window.recaptchaVerifier.render() 

As tuananh mentions, make sure you add a <div id="recaptcha"></div>.

like image 77
Alan Grainger Avatar answered Sep 22 '22 02:09

Alan Grainger