reCAPTCHA v3 doesn't return a token when an action specified

638 views
Skip to first unread message

Swapnil Tiwari

unread,
May 29, 2018, 6:12:13 AM5/29/18
to reCAPTCHA
I have integrated reCAPTCHA like so:
  1. Added this script - <script src='https://www.google.com/recaptcha/api.js?render=<my-site-key>'></script>
  2. Executed this code after the script has loaded:
           grecaptcha.ready(function() {
    grecaptcha.execute('<my-site-key>', {action: 'action_name'})
   .then(function(token) {
       console.log(token)
    });
   });

The console.log statement doesn't print anything in step 2. But when I remove the second parameter { action: 'Page Load' }, from the grecaptcha.execute method, I get a token in my console.

Why is this happening?
The docs don't talk about adding actions anywhere but the directly in the code.
Do I need to configure these actions somewhere before using them in the code?


Justin Svrcek

unread,
Jun 4, 2018, 5:35:56 AM6/4/18
to reCAPTCHA
You are probably using a v2 site key. In the v3 docs it asks you to create a v3 key at this link: https://g.co/recaptcha/v3
Reply all
Reply to author
Forward
0 new messages