Google reCAPTCHA v2 invalid domain for site key

Viewed 7769

I am currently trying to add reCAPTCHA on the client side and I have followed the documentation accordingly from both Google and reCAPTCHA's website. However, for some reason I keep getting this error message:

enter image description here
I've placed my script tag in the head and my reCAPTCHA div just before the closing form tag.

<!-- Google reCAPTCHA API -->
<script src='https://www.google.com/recaptcha/api.js' async defer>  </script>

<form action="URL: https://www.google.com/recaptcha/api/siteverify" method="POST"> -->
    <!-- reCAPTCHA Widget Appears Here -->
    <div class="g-recaptcha" data-theme="darklight" data-sitekey="my_public_sitekey"></div> -->
</form>

Please let me know if you need to see more of my code. From what I've read in other forums people had to disable domain name validation, however, that causes issues with verification.

Any help is much appreciated. Thanks!

3 Answers

After hours and days of research I've finally found a solution. This error is actually a reCAPTCHA issue that still has not been fixed. You can work around their protocol issues and disable domain check in advance settings. However, that can potentially mess up the validation process.

Initially I was testing this locally file:///users/file-path-to-my-file. Finally last night I found out you cannot use reCAPTCHA this way. I ended up testing my site publicly and now it works just fine. Hope this helps someone!

You have to replace my_public_sitekey with your site key which provided by Google

finally, your cod should be like this

<div class="g-recaptcha" data-theme="darklight" data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></div>

if you are testing your site in localhost, you should get a reCaptcha key for localhost.

Disable this option in settings:

Verify the Android package name of reCAPTCHA solutions.

This solved my problem.

Related