Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

recaptcha v3 frontend returning strange, emptyish (invalid?) result with )]}'

Tags:

recaptcha

I am trying to follow the instructions for reCAPTCHA v3 but can't seem to get even the basics down. Seems like the grecaptcha execute is returning a very strange, unusable result. I am testing this on localhost:7684

<script src='https://www.google.com/recaptcha/api.js?render=MYSITEKEY'> 
</script>
<script>
grecaptcha.ready(function() {
  grecaptcha.execute('MYSITEKEY', {action: 
'action_name'}).then(function(token) {
      console.log(token);
      alert(token);
  });
});
</script>
<form action="http://localhost:7684/botcheck" method="post">
    <input type="text" name="name" value="" placeholder="name" required />
    <button type="submit">submit</button>
</form>

The console is showing the token is null, and my chrome debugger is showing this response:

)]}'
["rresp",null,null,null,null,null,10]

chrome dev tools

like image 446
badcoder Avatar asked Mar 06 '23 04:03

badcoder


1 Answers

Ok, that was stupid. The problem was I had to change the action parameter to anything else. Looks like they return that result for the default action name "action_name"

like image 136
badcoder Avatar answered Apr 27 '23 08:04

badcoder