RecaptchaV3错误不正确-captcha-sol有时

incorrect-captcha-sol在使用 Google reCAPTCHA 服务器端验证 api 时有时会收到错误代码。

我已将 google recaptcha 验证集成到我的一些 api 中。

为此,我在来自客户端的这些 api 请求上传递了 recaptcha 令牌,然后通过遵循服务器端的 recaptcha验证在服务器端对其进行验证。

我通过执行以下代码获取 recaptcha 令牌并将此令牌传递给我的 api 请求标头:

  const getRecapthcaToken = () => {
   return new Promise((resolve, reject) => {
    try {
      if (window.grecaptcha && typeof window.grecaptcha.execute === "function") {
        grecaptchaExecute(window.grecaptcha.execute);
      } else {
        window.grecaptcha.ready(async () => {
          grecaptchaExecute(window.grecaptcha.execute);
        });
      }

      // grecaptcha execute action
      async function grecaptchaExecute(ExecuteAction) {
        const captchaToken = await ExecuteAction(
          xxxxxx, // my recaptcha site key
          {
            action: "submit",
          }
        );
        return resolve(captchaToken);
      }
    } catch (error) {
      return reject(error);
    }
  });
};

然后,在服务器端我打电话https://www.google.com/recaptcha/api/siteverify?secret=${secret_key}&response=${captchaToken}

大多数时候它工作正常,但有些调用失败并且incorrect-captcha-sol错误代码随机出现。

因为它是随机发生的,所以永远不知道它何时发生以及为什么发生。请帮我弄清楚,因为在 recaptcha 文档中,我也没有关于此错误代码的任何详细信息。

以上是RecaptchaV3错误不正确-captcha-sol有时的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>