7

I am getting the following error in Google Recaptcha V3 on my website.

ERROR for site owner: Invalid key type

enter image description here

I am using following method to verify captcha:

  1. adding script
<script src="https://www.google.com/recaptcha/api.js?render=API_KEY"></script>
  1. 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???

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 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 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 1

5

I'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. enter image description here

If you are using the node module in react, get more detail from this doc.

Not the answer you're looking for? Browse other questions tagged or ask your own question.