5

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

badcoder
  • 121
  • 1
  • 5

1 Answers1

7

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"

badcoder
  • 121
  • 1
  • 5
  • 4
    Wow, I spent more time on that than I should. Apparently we cannot use dashes or underscores in the names either, at least for now. – TheMechanic May 20 '18 at 23:03
  • Ha wasted time trying to debug that too, thanks for the question & answer! – James F May 22 '18 at 10:27
  • 1
    Hi folks... I'm having trouble with this. I already tried everything, diferent action names, no underscores, no hifens, no dashes, nothing. I'm getting something like this: )]}' ["rresp","03AGdBq27zFhZRdYeeOQWjxJk...",null,120,null,null,null,["bgdata","Ly93d3cuZ29vZ2xlLmNvbS9qcy9iZy9G..."] – Matheus Dal'Pizzol Jun 29 '20 at 15:13