不可见的重新验证 "We detected that your site is not verifying reCAPTCHA solutions"

invisible recaptcha "We detected that your site is not verifying reCAPTCHA solutions"

我正在我网站的登录页面上实施不可见的 recaptcha,遵循有关如何 "Automatically bind the challenge to a button" 的官方指南: https://developers.google.com/recaptcha/docs/invisible#auto_render

我的html页面是这样制作的:

    <head>
[...]
        <script src="js/login.js"></script>
        <script src="https://www.google.com/recaptcha/api.js" async defer></script>
    </head>
    <body>
[...]
            <button type="submit" class="g-recaptcha btn btn-primary" data-sitekey="[...]" data-callback="checkCaptcha" id="loginSubmit">Login <i class="fas fa-sign-in-alt"></i></button>
[...]
    </body>
    </html>

而 javascript 文件是:

    function checkCaptcha(token) {
        console.log("re-captcha callback invoked.");
        login();
    }


    function login() {
[...]
}

但在 Google 的面板页面上,我一直收到消息 "We detected that your site is not verifying reCAPTCHA solutions. This is required for the proper use of reCAPTCHA on your site. Please see our developer site for more information."

有人可以帮助我理解我错了什么吗?

非常感谢您的建议。

当用户在您的 html 页面解决验证码难题(或点击提交按钮)时 Google recaptcha 会向您的 <form> 添加另一个隐藏的输入值 [=11] =] 或解析给定的 data-callback 函数。它包含一个字符串值,您应该将其发送回 Google 以验证来自服务器端的响应。

没有服务器端验证部分recaptcha是无用的。 API申请详情如下,

URL: https://www.google.com/recaptcha/api/siteverify
方法:GET / POST(推荐)

参数:

  • secret(必需。您的站点和 reCAPTCHA 之间的共享密钥。)
  • response(必需。reCAPTCHA 提供的用户响应令牌,用于验证您网站上的用户。)
  • remoteip(可选。用户的 IP 地址。)

阅读 Google 关于 Verifying the user's response 的文档以了解更多信息。