Hello World
Hello World

Reputation: 2907

recaptcha v3 - ERROR for site owner: Invalid key type

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

Upvotes: 7

Views: 15904

Answers (1)

Cardoso
Cardoso

Reputation: 1088

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.

Upvotes: 5

Related Questions