reCAPTCHA:"ERROR for site owner: Invalid site key"

OtagoHarbour picture OtagoHarbour · Feb 3, 2018 · Viewed 73.6k times · Source

I tried to set up reCAPTCHA, on my page by following the instructions here. I signed up for an API key pair and was issued a public key and a private key. It was not clear, to me, how the private key should be used and I could not find more information about it. It does not appear to be used on the page where reCAPTCHA is called.

I edited my page and put

<script src='https://www.google.com/recaptcha/api.js'></script>

before the closing </head> tag on my HTML template.

I also put

<div class="g-recaptcha" data-sitekey="my-public-key"></div>

where I want my reCAPTCHA widget to appear.

When I load my page, I get the message

Cannot contact reCAPTCHA. Check your connection and try again.

I also see the reCAPTCHA widget with the text

ERROR for site owner: Invalid site key

I have checked similar questions such as this, where the answer says the key is probably invalid but I have just generated it. I also saw this but I did not disable

Verify the origin of reCAPTCHA solutions

Answer

Matthew Lock picture Matthew Lock · Jun 20, 2019

It wasn't obvious to me initially but you have to supply your site key in 2 places:

enter image description here