How to use token
After getTaskResult returns status: "ready" and the solution in solution, you need to deliver the token to the website. The delivery methods below are separated by captcha type.
reCAPTCHA v2 / v3#
For reCAPTCHA v2 and v3, the following are used:
| Method | What is used |
|---|---|
| Hidden form field | g-recaptcha-response |
| JS object/callback | grecaptcha.getResponse() is replaced by the token value, or the callback specified in data-callback is triggered |
Method 1: via a hidden form field#
Most websites put the token in a hidden <input> inside the form and simply submit the form. Find the corresponding field in the DOM and insert the value before submitting:
<textarea id="g-recaptcha-response" name="g-recaptcha-response"></textarea>
document.querySelector('#g-recaptcha-response').value = 'TOKEN_FROM_SOLUTION';
document.querySelector('form').submit();
Method 2: via a callback function#
If the widget is initialized with data-callback (or the JS callback parameter in grecaptcha.render()), the website expects a call to this function with the token as an argument, not a form submission. Each website has its own function name. You need to check it in the markup (data-callback="onCaptchaSolved") or in the widget JS initialization:
// reCAPTCHA v2/v3 with callback
onCaptchaSolved('TOKEN_FROM_SOLUTION');
Before choosing a method, open the Network tab in your browser developer tools and solve the captcha manually. This will show whether the token is sent as a form field (POST with g-recaptcha-response in the body) or passed to a JS callback without an explicit form submission.
Cloudflare Turnstile#
For Turnstile, the following are used:
| Method | What is used |
|---|---|
| Hidden form field | cf-turnstile-response |
| JS object/callback | callback specified in the Turnstile widget data-callback or in the callback parameter of turnstile.render() |
Method 1: via a hidden form field#
Most websites put the token in a hidden <input> inside the form and simply submit the form. Find the corresponding field in the DOM and insert the value before submitting:
<input type="hidden" name="cf-turnstile-response" id="cf-turnstile-response">
document.querySelector('#cf-turnstile-response').value = 'TOKEN_FROM_SOLUTION';
document.querySelector('form').submit();
Method 2: via a callback function#
If the widget is initialized with data-callback (or the JS callback parameter in turnstile.render()), the website expects a call to this function with the token as an argument, not a form submission. Each website has its own function name. You need to check it in the markup (data-callback="onTurnstileSolved") or in the widget JS initialization:
// Turnstile with callback
onTurnstileSolved('TOKEN_FROM_SOLUTION');
Before choosing a method, open the Network tab in your browser developer tools and solve the captcha manually. This will show whether the token is sent as a form field (POST with cf-turnstile-response in the body) or passed to a JS callback without an explicit form submission.