Created
April 22, 2020 03:26
-
-
Save shellj/afb66de1c6316d2316b4b14c979d271c to your computer and use it in GitHub Desktop.
reCAPTCHA v3 Invalid site key or not loaded in api.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recaptcha__zh_cn.js:534 Uncaught Error: Invalid site key or not loaded in api.js: xxxxxxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Hello</title> | |
</head> | |
<body> | |
<h3>hello</h3> | |
<button onclick='cha()'>go</button> | |
<script src="https://recaptcha.net/recaptcha/api.js?render=xxxxxxx"></script> | |
<script> | |
function cha() { | |
grecaptcha.execute('xxxxxxx', {action: 'homepage'}).then(function(token) { | |
console.log('token:' + token); | |
}); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recaptcha script must be connected with public key, like:
<script src="https://www.google.com/recaptcha/api.js?render=XXXXXXXXXXXXX__PUBLIC_KEY_XXXXXXXXX"></script>In my case, problem was: there was't key in this line, it was like:
<script src="https://www.google.com/recaptcha/api.js?render="></script>(it was PHP error)
I think, you can get same error if you will use DIFFERENT public keys in the JS script connection and in the recaptcha execute method:
grecaptcha.execute('XXXXXXXXXXXXX__PUBLIC_KEY_XXXXXXXXX', {action: 'homepage'}).then(function (token) { var captchaElems = document.getElementsByClassName('g-recaptcha-response-v3'); for (var i = 0; i < captchaElems.length; i++) { captchaElems[i].value = token; } });