I am using the Google reCaptcha in iOS and android native apps, which is working fine. But I also want to implement the Google ReCaptcha in MacOS app as well. Google ReCaptcha Enterprise dose not offer any lib or SDK for MacOS. So I was trying to user the Google ReCaptchs in WebView in MacOS using java Script code.
But I am always getting the error : “ERROR for site owner: Invalid domain for site key”, when loading that page in Web view in MacOS app.
I am using below code for implementing it
<html>
<head>
<script src="https://www.google.com/recaptcha/enterprise.js?render=MY_KEY"></script>
<script>
function onSubmit() {
grecaptcha.enterprise.ready(function() {
grecaptcha.enterprise.execute('MY_KEY', {action: 'LOGIN'}).then(function(token) {
window.webkit.messageHandlers.recaptchaCallback.postMessage(token);
});
});
}
</script>
</head>
<body>
<button onclick="onSubmit()">Verify</button>
</body>
</html>
This same code is working fine when I tried in online html compiler in browser.
Any idea why Google ReCaptcha is not working when loaded using java script in MacOS’s webview ?
Also please let me know if there is any other way to implement Google ReCaptcha in MacOS App ?
Thanks.