This is virtually identical to recaptcha v3 frontend returning strange, emptyish (invalid?) result with )]}'
On the recaptcha settings page - https://www.google.com/recaptcha/admin/site/.../settings I have
- chosen recaptcha v3
- set up domains, etc.
- generated keys
The only differences I can see between the previous stackoverflow question and my case now are:
- I am not using localhost,
- my action is already all alpha characters, and
- I am still getting that strange response
In that previous question apparently the poster changed the action name and all was well. I've fiddled around with the action name and it hasn't changed anything. I'll show the response details below. Before I do that, here is an extract of the relevant code from my page:
<script src="https://www.google.com/recaptcha/api.js?render=MYKEY"></script>
<script>
grecaptcha.ready(function () {
grecaptcha.execute('MYKEY', {action: 'contactpage'});
});
<script>
And here is what happens when I run it. The results are the same in Chrome and Firefox. In the browser console I see this response:
XHR POST https://www.google.com/recaptcha/api2/reload?k=*MYKEY*
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Response Payload
)]}'
["rresp"," ... (and much more)... ]
The recaptcha api url in the script tag is clearly different from the url shown in the console, which is fine by me. Obviously a lot is going on under the covers.