Skip to content

Instantly share code, notes, and snippets.

@shangyilim
Last active June 15, 2022 12:53
Show Gist options
  • Save shangyilim/af185e69e8a0de4e754c3e4908f9f922 to your computer and use it in GitHub Desktop.
Save shangyilim/af185e69e8a0de4e754c3e4908f9f922 to your computer and use it in GitHub Desktop.
// set-up an invisible recaptcha. 'sendCode` is button element id
// <button id="sendCode">Send Code</button>
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sendCode', {
'size': 'invisible',
'callback': function (recapchaToken) {
// reCAPTCHA solved, send recapchaToken and phone number to backend.
// a REST call to your backend
request.post({
url: 'https://your-rest-api',
body: {
phoneNumber: document.getElementById('phoneNumber').value,
recapchaToken,
}
});
}
});
// render the rapchaVerifier.
window.recaptchaVerifier.render().then(function (widgetId) {
window.recaptchaWidgetId = widgetId;
});
@sanket-hv
Copy link

Where do I need to put this code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment