NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

Glossary

CAPTCHA callback function

A callback is the JavaScript function a CAPTCHA widget calls with the token when the visitor passes, and many pages only move forward when it runs.

Definition

Widgets such as reCAPTCHA, Turnstile and MTCaptcha let the page register a function that receives the token the moment it exists. In HTML it is named in an attribute, for example data-callback="onCaptchaOk". In code it is passed as an option, for example grecaptcha.render(el, {sitekey: k, callback: onCaptchaOk}). The widget calls onCaptchaOk(token) after a pass, and the page decides what to do next.

Sites use callbacks because they want control. A callback can enable a disabled button, store the token in application state, send an XHR request instead of a classic form post, or start the next step of a wizard.

Why injecting the token alone may not work

When you solve a CAPTCHA through an API, the widget in the page never passes on its own. You place the token into the hidden field yourself, but nothing tells the page that this happened. If the page logic sits inside the callback, then:

  • the submit button stays disabled because the code that enables it never ran;
  • a single page app never copies the token into its state, so the request goes out with an empty value;
  • a form submitted by script in the callback is never submitted at all.

The symptom is a page that looks finished but does not react. Calling the callback with your token fixes it, because you are doing exactly what the widget would have done.

Finding the callback

Check the widget's container or button first for data-callback. If there is none, search scripts for callback: near render(. On reCAPTCHA pages, the configuration object is reachable from the console:

// Walk the reCAPTCHA client config and print any callbacks found
function findCallbacks(node, trail = "cfg", seen = new Set()) {
  if (!node || typeof node !== "object" || seen.has(node)) return;
  seen.add(node);
  for (const [key, val] of Object.entries(node)) {
    const here = trail + "." + key;
    if (key === "callback") console.log(here, val);
    else findCallbacks(val, here, seen);
  }
}
findCallbacks(window.___grecaptcha_cfg?.clients);

The printed value is either a function or a string with the function name. Either way, you can invoke it. For Turnstile, look for callback in the options passed to turnstile.render.

Calling it from automation

In a browser driver, set the token in the hidden field and then call the function with the same token. With Selenium in Python that is driver.execute_script("window[arguments[0]](arguments[1])", name, token) when the callback is a global function name. If it is an anonymous function stored in the config, call it through the path the search above printed.

Do both steps: some callbacks read the hidden field instead of their argument, and some servers read the field while the callback only enables the button.

Callbacks without a browser

If you use plain HTTP, there is nothing to call. Instead, read what the callback does: usually it sends one request with the token and a few other values. Reproduce that request directly. Developer tools show it in the network tab the moment you pass a widget by hand.

Related callbacks

Widgets also offer expired-callback and error-callback. Pages sometimes clear the token field or disable the button when the expiry callback fires. If you inject a token and then wait a few minutes, that logic can undo your work, so submit promptly. The callback finding guide and the g-recaptcha-response entry cover the surrounding steps.

Testing that the handoff worked

After calling the callback, check for a visible change before you move on: the button becomes clickable, a spinner appears, or a request to the form's endpoint shows up in the network log. In Playwright you can wait for that request with page.waitForRequest and assert that its body contains the token. A check like this turns a silent failure into a clear error in your logs, which saves hours when a site changes its front end.

Common questions

How do I know if a page uses a callback?

Look for data-callback on the widget or a callback option in the render call. A submit button that starts disabled is another strong sign.

Should I still fill the hidden field if I call the callback?

Yes. Some pages read the field on submit and use the callback only to enable the button, so doing both is safest.

What if the callback is an anonymous function?

Reach it through the widget configuration object, such as ___grecaptcha_cfg.clients for reCAPTCHA, and call it from there.

Does Turnstile have callbacks too?

Yes. Turnstile supports callback, expired-callback and error-callback options with the same idea as reCAPTCHA.

Can I avoid callbacks entirely?

With a plain HTTP client, yes: send the request the callback would send, with the solved token in the right field.

Keep reading