javascript - recaptcha v3 - 网站所有者的错误:无效的密钥类型
问题描述
我在我的网站上的 Google Recaptcha V3 中收到以下错误。
网站所有者的错误:无效的密钥类型
我正在使用以下方法来验证验证码:
- 添加脚本
<script src="https://www.google.com/recaptcha/api.js?render=API_KEY"></script>
- 在提交验证:
$('.submit-e-way-bill-registration').on('submit', function (e) {
e.preventDefault();
var self = this;
if ($(self)[0].checkValidity()) {
grecaptcha.ready(function () {
grecaptcha.execute('API_KEY', {
action: 'homepage'
}).then(function (token) {
console.log(token);
console.log('google captcha initiated');
$('[name=captcha_token]').val(token);
var data = $(self).serialize();
$('.save-button-ewb').prop('disabled', true);
$.post('/api/submit-e-way-bill-registration.php', data, function (result) {
$('.save-button-ewb').prop('disabled', false);
console.log('status');
if (result.status == 'success') {
$('.success-message').show();
$('.submit-e-way-bill-registration').hide();
} else {
$('.error-message').show();
$('.submit-e-way-bill-registration').hide();
}
});
});
});
}
});
这曾经以这种方式工作(大约 3-4 个月前)。现在,当我检查时,我收到了上述错误。
谁能告诉我代码有什么问题???
解决方案
几天前我遇到了这种错误。我通过生成正确的 ReCaptcha 站点的客户端密钥解决了这个问题。在我看来,您的脚本需要 google ReCaptcha v2,但您使用的是 v3。请检查此屏幕截图。这解决了我的问题。
如果您在 react 中使用节点模块,请从此文档获取更多详细信息。
推荐阅读
- c++ - 调用 transformNodeToObject 失败
- xslt - 在 XSLT 中选择节点的各种位置
- react-native - 如何在图像上显示相机图标
- c# - AWS:在 Amazon 中自动调用 API
- javascript - 在滚动时更改选取框方向而不更改其当前位置
- jquery - 当我在 jquery 中调用 ID 时表单不提交,但是当我将 id 更改为类时表单提交
- asp.net-core-webapi - 如何删除 WebAPI 核心中的 WebDAV 模块?
- html - 允许在 Electron 中使用需要外部文件的 HTML 文件
- angular - 对 *ngFor 使用带有三元运算符的自定义管道
- node.js - 将 LoopBack4 连接到 REST API 和 Swagger