Google Re-captcha not working in webview android kotlin

186 views Asked by At

i am trying to integrate google re-captcha using webview along with html script.

and captca open successfully but after verify the checkbox i need captcha success token so that i can verify this with my server token, but i am getting below error.

APi i am going to hit to verify captcha = --- D onLoadResource>>>URLhttps://www.google.com/recaptcha/api2/userverify?k=6Lcs_l8nAAAAALLBhU15tSmAbAckZ-e-zN60pQ0D

Error =

I [INFO:CONSOLE(0)] "Uncaught (in promise) ReferenceError", source: https://www.google.com/recaptcha/api2/anchor?ar=1&k=${siteKey}&co=aHR0cHM6Ly9zb3VnaGFoYWRtaW4uZGVtby5icmFpbnZpcmUuZGV2OjQ0Mw..&hl=en&v=MydHw_zggsxIJuhSbyOmPv5R&size=normal&cb=6w8qa2axyise (0)

Html script

private fun getHtmlWithReCAPTCHA(): String { return """ const post = function(value) { MyJavaScriptInterface.onTokenReceived(value); };

            console.log = function(message) {
              post(message);
            };

            var onLoad = function() {
              grecaptcha.render(
                "recaptcha",
                {
                  sitekey: "$siteKey",
                  callback: function(token) {
                    post(token);
                  },
                  size: "normal"
                }
              );

              // Inject your provided JavaScript code here
              grecaptcha.execute('$siteKey', { action: 'submit' }, function(token) {
                MyJavaScriptInterface.onTokenReceived(token);
              });
            };
          </script>
        </head>
        <body>
          <div id="recaptcha"></div>
        </body>
        </html>
    """.trimIndent()
}

i have tried to use safety net api but by using that i am not accessing google re-captcha in Oman region. that is why i am trying to add captcha with webview

0

There are 0 answers