Google 网站所有者的 reCAPTCHA 错误:无效的网站密钥
Google reCAPTCHA ERROR for site owner: Invalid site key
我无法在我的网站上使用 reCAPTCHA v3。我已经从 Google reCAPTCHA v3 网站输入了正确的代码,但它在右下角显示了 "ERROR for site owner: Invalid site key"。
我才7岁,如果有什么遗漏,请不要着急
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Recaptcha test</title>
<script src="https://www.google.com/recaptcha/api.js"></script>
<script>
function onSubmit(token) {
document.getElementById("demo-form").submit();
}
</script>
<script src="https://www.google.com/recaptcha/api.js?render=reCAPTCHA_site_key"></script>
<body>
<button class="g-recaptcha"
data-sitekey="reCAPTCHA_site_key"
data-callback='onSubmit'
data-action='submit'>Submit</button>
<script>
function onClick(e) {
e.preventDefault();
grecaptcha.ready(function() {
grecaptcha.execute('reCAPTCHA_site_key', {action: 'submit'}).then(function(token) {
// Add your logic to submit to your backend server here.
});
});
}
</script>
</head>
</body>
</html>
然后,我尝试了 reCAPTCHA v2 Checkbox,同样的事情发生了。虽然,"ERROR for site owner: Invalid site key" 现在在左上角:
<!DOCTYPE html>?
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Recaptcha test</title>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
async defer>
</script>
<body>
<form action="?" method="POST">
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
<br/>
<input type="submit" value="Submit">
</form>
<script type="text/javascript">
var onloadCallback = function() {
alert("grecaptcha is ready!");
};
</script>
</head>
</body>
</html>
我试过你提到的reCAPTCHA v3代码。
reCAPTCHA_site_key 在三个地方,请检查您是否已将其替换为标题下的正确站点密钥:"COPY SITE KEY"
.
显示 "ERROR for site owner: Invalid site key" 的原因是您可能正在尝试通过文件系统访问密钥。它在文件系统上不起作用,即,这不起作用:file:///E:/Personal%20Data/Whosebug/recapcha.html
在本地服务器上托管您的站点,例如 IIS/Node 等,并在 recaptcha 的域配置中添加相同的域。
for example if your website is: https://www.testingrecapcha.com/ then add testingrecapcha.com in domains of rechapcha configurations. (to reach admin console of recapcha, use this: https://www.google.com/recaptcha/admin and select your relevant site and click on settings icon).
我无法在我的网站上使用 reCAPTCHA v3。我已经从 Google reCAPTCHA v3 网站输入了正确的代码,但它在右下角显示了 "ERROR for site owner: Invalid site key"。
我才7岁,如果有什么遗漏,请不要着急
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Recaptcha test</title>
<script src="https://www.google.com/recaptcha/api.js"></script>
<script>
function onSubmit(token) {
document.getElementById("demo-form").submit();
}
</script>
<script src="https://www.google.com/recaptcha/api.js?render=reCAPTCHA_site_key"></script>
<body>
<button class="g-recaptcha"
data-sitekey="reCAPTCHA_site_key"
data-callback='onSubmit'
data-action='submit'>Submit</button>
<script>
function onClick(e) {
e.preventDefault();
grecaptcha.ready(function() {
grecaptcha.execute('reCAPTCHA_site_key', {action: 'submit'}).then(function(token) {
// Add your logic to submit to your backend server here.
});
});
}
</script>
</head>
</body>
</html>
然后,我尝试了 reCAPTCHA v2 Checkbox,同样的事情发生了。虽然,"ERROR for site owner: Invalid site key" 现在在左上角:
<!DOCTYPE html>?
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Recaptcha test</title>
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
async defer>
</script>
<body>
<form action="?" method="POST">
<div class="g-recaptcha" data-sitekey="your_site_key"></div>
<br/>
<input type="submit" value="Submit">
</form>
<script type="text/javascript">
var onloadCallback = function() {
alert("grecaptcha is ready!");
};
</script>
</head>
</body>
</html>
我试过你提到的reCAPTCHA v3代码。
reCAPTCHA_site_key 在三个地方,请检查您是否已将其替换为标题下的正确站点密钥:
"COPY SITE KEY"
.显示 "ERROR for site owner: Invalid site key" 的原因是您可能正在尝试通过文件系统访问密钥。它在文件系统上不起作用,即,这不起作用:
file:///E:/Personal%20Data/Whosebug/recapcha.html
在本地服务器上托管您的站点,例如 IIS/Node 等,并在 recaptcha 的域配置中添加相同的域。
for example if your website is: https://www.testingrecapcha.com/ then add testingrecapcha.com in domains of rechapcha configurations. (to reach admin console of recapcha, use this: https://www.google.com/recaptcha/admin and select your relevant site and click on settings icon).