How to solve reCAPTCHA v2 callback
Are you developing a scraper or automating tests but running into reCAPTCHA? This guide will show you how to programmatically extract key captcha parameters (sitekey, version, callback) from a webpage and use them to bypass protection via API services. You'll learn how to run a ready-made script in the browser console, submit tasks for solving, and correctly inject the token back into the form.
Quick Start
- Open the page with reCAPTCHA in your browser →
F12→ Console tab - Paste the
findRecaptchaClients()function code from GitHub Gist - Run
findRecaptchaClients()and copysitekey,version,pageurlfrom the output - Submit a task to a captcha-solving service via API
- Receive the token and inject it into the
#g-recaptcha-responsefield or pass it via thecallbackfunction
Video Guide
Prefer visual learning? Our video tutorial covers everything in this article with a live demonstration:
Watch the complete video guide:
What's inside the video:
- Real-time demo: Watch the entire workflow from start to finish on a live test page
- Console walkthrough: See exactly how to paste and run
findRecaptchaClients()without mistakes - Parameter extraction: Learn how to read the JSON output and identify which values matter
- API integration: Observe how to construct the API request using the extracted parameters
- Token injection: Visual demonstration of injecting the token and triggering the callback function
- Common pitfalls: See typical errors and how to avoid them in real-time
Video length: ~1 minute
Difficulty: Beginner-friendly — no prior experience required
💡 Pro tip: Watch the video first to get the big picture, then use this article as a reference while implementing it on your own project.
Step-by-Step Instructions
🔹 Step 1: Preparation and Opening the Console
- Load the target page in Chrome/Firefox
- Make sure the reCAPTCHA widget is fully rendered (sometimes a scroll or click is required)
- Open DevTools:
F12orCtrl+Shift+I→ Console tab
🔹 Step 2: Running the findRecaptchaClients Script
- Copy the function code from the official Gist
- Paste it into the console and press
Enter - Execute the command:
javascript
findRecaptchaClients()
🔹 Step 3: Analyzing Results and Extracting Parameters
The script returns an array of objects. Example:
json
[
{
"id": "0",
"version": "V2",
"sitekey": "6LcTmlolAAAAAKcDAZQE0o-1rBJ4R2xz...",
"callback": "___grecaptcha_cfg.clients['0']['C']['C']['callback']",
"pageurl": "https://example.com/login"
}
]
What to copy:
sitekey— the unique site keyversion— V2 (checkbox) or V3 (invisible)pageurl— exact page URL (critical for validation)callback— optional, only if an explicit handler function exists
🔹 Step 4: Submitting the Task to the Service
Python example for reCAPTCHA v2:
python
import requests, time
API_KEY = 'your_api_key'
response = requests.post('https://api.rucaptcha.com/createTask', json={
'clientKey': API_KEY,
'task': {
'type': 'RecaptchaV2TaskProxyless',
'websiteURL': 'https://example.com/login',
'websiteKey': '6LcTmlolAAAAAKcDAZQE0o-1rBJ4R2xz...'
}
})
task_id = response.json()['taskId']
# Wait for solution
while True:
res = requests.post('https://api.rucaptcha.com/getTaskResult', json={
'clientKey': API_KEY, 'taskId': task_id
}).json()
if res['status'] == 'ready':
token = res['solution']['gRecaptchaResponse']
break
time.sleep(5)
🔹 Step 5: Injecting the Token Back into the Page
python
# Inject token into hidden field
driver.execute_script(
f"document.getElementById('g-recaptcha-response').value = '{token}';"
)
# Call callback if it exists
if callback:
driver.execute_script(f"{callback}('{token}')")
# OR simply submit the form if no callback is present
Comparing Solutions
| Method | Pros | Cons | When to Use |
|---|---|---|---|
| Manual HTML inspection | No scripts required | Unreliable; parameters hidden in JS | Simple cases only |
| findRecaptchaClients script | ✅ Finds all captchas on page, extracts callback | Requires browser console execution | Primary recommended method |
| Browser extensions | User-friendly UI | May become outdated, limited functionality | One-off tasks |
| Headless scraping with Puppeteer/Playwright | Full automation | More complex setup, resource-intensive | Production scrapers |
Errors and Debugging
| Error | Likely Cause | Solution |
|---|---|---|
Script returns [] |
Captcha not loaded / dynamic loading | Wait for widget to appear; add setTimeout or trigger event |
callback is not a function |
Callback inside iframe / not globally exported | Switch to iframe: driver.switch_to.frame(...) before execution |
| Token rejected by site | pageurl mismatch, token expired |
Verify exact URL match (including trailing /); use token immediately |
| Repeated requests blocked | Site detects anomalous activity | Add delays, use proxies, rotate User-Agent |
Tip for dynamic captchas:
Run findRecaptchaClients() right before each request — don't cache sitekey long-term.
FAQ
Q: What if there are multiple captchas on the page?
A: The script returns an array — select the correct object by pageurl or visual position.
Q: Can I use this method for hCaptcha or Cloudflare?
A: No, this script works only with reCAPTCHA. Other protections require separate solutions.
Q: How can I verify the token is valid before submitting the form?
A: Send it for verification via the Google Site Verify API (requires the site's secret key).
Q: What if the site uses reCAPTCHA Enterprise?
A: The principle is the same, but additional behavioral signal emulation may be required.
Q: Is it safe to store the API key in code?
A: No. Use environment variables or your CI/CD secrets manager.
Summary
You've learned how to:
- Extract
sitekey,version, andcallbackvia the browser console - Submit tasks to a captcha-solving service
- Correctly inject the token into the page to bypass protection
What to do next:
- Test the script on your target page
- Integrate the code example into your scraper or test suite
- Set up error handling and logging
- For production, add proxy rotation and request delays
Helpful Resources:
- findRecaptchaClients script on GitHub
- Video setup guide
- API Documentation
- Code examples for Python, JS, C# and more in our blog
Need help?
Contact support — the team responds quickly and can help with integration.
Final tip: Always verify parameter freshness on each run — sites can change their captcha implementation without notice.