I am getting the following error in Google Recaptcha V3 on my website.
ERROR for site owner: Invalid key type
I am using following method to verify captcha:
- adding script
<script src=".js?render=API_KEY"></script>
- on submit verify:
$('.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();
}
});
});
});
}
});
This used to work before (about 3-4 months ago) this way. Now when I am checking I am getting the above error.
Can anyone tell me what is wrong in the code???
I am getting the following error in Google Recaptcha V3 on my website.
ERROR for site owner: Invalid key type
I am using following method to verify captcha:
- adding script
<script src="https://www.google./recaptcha/api.js?render=API_KEY"></script>
- on submit verify:
$('.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();
}
});
});
});
}
});
This used to work before (about 3-4 months ago) this way. Now when I am checking I am getting the above error.
Can anyone tell me what is wrong in the code???
Share Improve this question edited Jun 29, 2020 at 10:28 Hello World asked Jun 29, 2020 at 10:16 Hello WorldHello World 2,9077 gold badges31 silver badges66 bronze badges 4- I'd guess there's something wrong with the key, not the code. Can you go back to your ReCaptcha dashboard and check the key, or generate a new key? – Rup Commented Jun 29, 2020 at 10:37
- 1 I checked that, but there is nothing wrong with key!! @Rup – Hello World Commented Jun 29, 2020 at 10:53
- @Rup but a strange thing is I can still submit the form and validation is working. But error is still showing – Hello World Commented Jun 29, 2020 at 10:55
- 2 Some other suggestions here: reCAPTCHA:“ERROR for site owner: Invalid site key”. If they don't help you'll probably have to ask Google. – Rup Commented Jun 29, 2020 at 11:28
1 Answer
Reset to default 5I've met that kind of error a few days ago. I solved that problem by generating the correct ReCaptcha site's client-key. In my opinion, your script wants google ReCaptcha v2, but you are using v3. Please have a check this screenshot. This solved my problem.
If you are using the node module in react, get more detail from this doc.