Was this helpful?
How to bypass reCAPTCHA v2 Invisible
Technical engineer
Introduction
reCAPTCHA v2 Invisible is Google's hidden CAPTCHA variant that operates in the background without requiring explicit user interaction with a widget. Unlike the classic reCAPTCHA v2 checkbox ("I'm not a robot"), the invisible version triggers automatically when specific actions occur on the page: clicking a button, submitting a form, or loading content.
For developers working on automation, testing, or web scraping, reCAPTCHA v2 Invisible presents a unique challenge: the CAPTCHA isn't visually displayed, yet it blocks target actions until verification is complete.
This article serves as a practical guide to bypassing reCAPTCHA v2 Invisible using the 2Captcha API. You'll learn how to identify CAPTCHA parameters, submit a solving task, retrieve the token, and properly inject it into the page.
What Is reCAPTCHA v2 Invisible
reCAPTCHA v2 Invisible is a verification mechanism that:
- Does not display a visible widget on the page
- Triggers automatically upon user actions (clicks, form submissions)
- Uses a callback function to handle verification results
- Requires token submission via a callback function rather than a form field
Key Differences from Standard reCAPTCHA v2:
| Feature | reCAPTCHA v2 (Checkbox) | reCAPTCHA v2 Invisible |
|---|---|---|
| Visible widget on page | Yes ("I'm not a robot" checkbox) | No (hidden verification) |
| Activation | User clicks the checkbox | Automatically upon action |
| Token field | g-recaptcha-response | Callback function |
| isInvisible parameter | false or omitted | true |
Required API Parameters
To solve reCAPTCHA v2 Invisible via the 2Captcha API, you'll need the following parameters:
Mandatory Parameters
| Parameter | Description | Example |
|---|---|---|
| type | Task type: RecaptchaV2TaskProxyless or RecaptchaV2Task | "RecaptchaV2TaskProxyless" |
| websiteURL | Full URL of the page containing the CAPTCHA | "https://target-site.com/login" |
| websiteKey | CAPTCHA sitekey (data-sitekey attribute) | "6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u" |
| isInvisible | Flag for invisible version | true |
Additional Recommended Parameters
| Parameter | Description | Example |
|---|---|---|
| userAgent | Browser User-Agent for session consistency | "Mozilla/5.0 (Windows NT 10.0; Win64; x64)..." |
| cookies | Cookies for authenticated sessions | "session_id=abc123; user=john" |
| recaptchaDataSValue | Value of the data-s parameter (for Google services) | "some_value" |
| apiDomain | reCAPTCHA loading domain: google.com or recaptcha.net | "recaptcha.net" |
Proxy Parameters (for RecaptchaV2Task type)
| Parameter | Description | Example |
|---|---|---|
| proxyType | Proxy type: http, socks4, socks5 | "http" |
| proxyAddress | Proxy server IP or hostname | "1.2.3.4" |
| proxyPort | Proxy server port | 8080 |
| proxyLogin | Proxy authentication username | "proxy_user" |
| proxyPassword | Proxy authentication password | "proxy_pass" |
How to Find reCAPTCHA v2 Invisible Parameters
Step 1: Identifying the Sitekey
- Open the target page in your browser
- Launch DevTools (F12) → Elements or Network tab
- Locate the CAPTCHA element—typically a
<div>with classg-recaptchaand adata-sitekeyattribute
html
<div class="g-recaptcha"
data-sitekey="6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u"
data-callback="onSubmit"
data-size="invisible">
</div>
- Copy the data-sitekey value—this is your websiteKey
Step 2: Finding the Callback Function
For the invisible version, identifying the callback function name is critical:
- In the same element, locate the data-callback attribute
- The attribute value is the function name you'll need to invoke with the token
Example: data-callback="onSubmit" → call onSubmit(token)
Step 3: Alternative Method – Console Script
If parameters are hidden or dynamically loaded, use this script to extract reCAPTCHA data:
javascript
function findRecaptchaClients() {
if (typeof ___grecaptcha_cfg === 'undefined') return [];
return Object.entries(___grecaptcha_cfg.clients).map(([cid, client]) => {
const data = {
id: cid,
version: client['C'] ? 'V3' : 'V2',
sitekey: client['C']?.['k'] || client['k'],
callback: client['C']?.['C']?.['callback']?.toString() || null,
action: client['C']?.['C']?.['action'] || null
};
return data;
}).filter(item => item.sitekey);
}
console.log(JSON.stringify(findRecaptchaClients(), null, 2));
Run this script in your browser console—it returns an array of objects containing parameters for all CAPTCHAs on the page.
API Task Types
RecaptchaV2TaskProxyless (Recommended)
Uses 2Captcha's internal proxy pool. Suitable for most use cases.
json
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "RecaptchaV2TaskProxyless",
"websiteURL": "https://target-site.com/login",
"websiteKey": "6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u",
"isInvisible": true
}
}
RecaptchaV2Task (With Your Proxy)
Use when a fixed IP address is required (e.g., for Google services).
json
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "RecaptchaV2Task",
"websiteURL": "https://target-site.com/login",
"websiteKey": "6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u",
"isInvisible": true,
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)...",
"cookies": "session=abc123",
"proxyType": "http",
"proxyAddress": "1.2.3.4",
"proxyPort": 8080,
"proxyLogin": "user",
"proxyPassword": "pass"
}
}
Bypass Algorithm for reCAPTCHA v2 Invisible
- Preparation: Obtain your API key from your 2Captcha dashboard
- Parameter Collection: Identify websiteKey, websiteURL, and the callback function
- Task Submission: Create a task via the createTask endpoint
- Wait for Solution: Poll getTaskResult at 5-second intervals
- Retrieve Token: Extract gRecaptchaResponse from the response
- Inject Token: Invoke the callback function with the obtained token
Code Example: Python + SeleniumBase
python
import time
import requests
from seleniumbase import Driver
API_KEY = "YOUR_API_KEY"
SITE_KEY = "6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u"
PAGE_URL = "https://target-site.com/login"
CALLBACK_NAME = "onSubmit" # callback function name from data-callback
def solve_recaptcha_invisible(sitekey, url, callback_name=None):
"""Submits a task to solve reCAPTCHA v2 Invisible"""
payload = {
"clientKey": API_KEY,
"task": {
"type": "RecaptchaV2TaskProxyless",
"websiteURL": url,
"websiteKey": sitekey,
"isInvisible": True
}
}
# Submit task
response = requests.post(
f"https://api.2captcha.com/createTask",
json=payload
)
task_id = response.json()["taskId"]
# Wait for solution
while True:
time.sleep(5)
result = requests.post(
f"https://api.2captcha.com/getTaskResult",
json={"clientKey": API_KEY, "taskId": task_id}
).json()
if result["status"] == "ready":
return result["solution"]["gRecaptchaResponse"]
elif result["errorId"] != 0:
raise Exception(f"API Error: {result.get('errorDescription')}")
# Initialize browser in UC mode (Undetected Chromedriver)
driver = Driver(uc=True, headless=False)
try:
# Navigate to target page
driver.get(PAGE_URL)
time.sleep(3)
# Solve CAPTCHA
token = solve_recaptcha_invisible(SITE_KEY, PAGE_URL)
print(f"Token received: {token[:50]}...")
# Inject token via callback function
if CALLBACK_NAME:
driver.execute_script(f"{CALLBACK_NAME}('{token}');")
else:
# Fallback: insert into hidden field and submit form
driver.execute_script(
f"document.getElementById('g-recaptcha-response').value = '{token}';"
)
driver.execute_script("document.querySelector('form').submit();")
# Verify result
time.sleep(5)
if "success" in driver.page_source.lower():
print("CAPTCHA successfully bypassed!")
else:
print("Token validation may have failed")
finally:
driver.quit()
Working with Callback Functions
Why Callbacks Matter for the Invisible Version
With invisible reCAPTCHA v2, websites don't directly check the g-recaptcha-response field. Instead, they expect a specific JavaScript function to be called with the token. Simply injecting the token into a hidden field may not trigger the expected behavior.
How to Find and Invoke the Callback
-
Via DevTools:
- Open the Elements tab
- Locate
<div class="g-recaptcha"> - Copy the
data-callbackattribute value
-
Via Console:
javascript// List all reCAPTCHA callback functions on the page Object.values(___grecaptcha_cfg.clients).forEach(client => { const cb = client['C']?.['C']?.['callback']; if (cb) console.log('Callback:', cb.toString()); }); -
Invoke the Callback:
javascript// If callback is named "onSubmit" onSubmit('03AGdBq24PxK...');
If the Callback Isn't Globally Accessible
Sometimes the callback function is defined within a closure or iframe. In such cases:
python
# Attempt to locate callback by scanning global functions
driver.execute_script("""
for (let prop in window) {
if (typeof window[prop] === 'function' &&
(prop.toLowerCase().includes('recaptcha') ||
prop.toLowerCase().includes('submit'))) {
console.log('Possible callback:', prop);
}
}
""")
Error Handling
Common API Errors
| Error Code | Description | Solution |
|---|---|---|
| ERROR_WRONG_USER_KEY | Invalid API key | Verify your key in the dashboard |
| ERROR_KEY_DOES_NOT_EXIST | Key not found | Ensure the key is active |
| ERROR_ZERO_BALANCE | Insufficient funds | Top up your account balance |
| ERROR_NO_SLOT_AVAILABLE | No available workers | Retry after 10–20 seconds |
| ERROR_CAPTCHA_UNSOLVABLE | CAPTCHA cannot be solved | Verify parameters; try with proxy |
| ERROR_WRONG_CAPTCHA_ID | Invalid taskId | Use the current taskId from createTask |
Website-Side Errors
| Symptom | Possible Cause | Solution |
|---|---|---|
| Token rejected | Expired token (~2 min lifetime) | Inject token immediately after retrieval |
| Site ignores token | Callback not invoked | Locate and call the data-callback function |
| IP blocking | Suspicious activity from single address | Use residential proxies |
| CAPTCHA fails to load | Dynamic widget loading | Add delay before collecting parameters |
Best Practices
-
Use UC Mode in Selenium: Undetected Chromedriver mode hides automation signals from Google detectors.
-
Synchronize User-Agent: Pass the same User-Agent to the API request that your browser uses.
-
Work with Sessions: Include cookies in your API task if the site requires authentication.
-
Avoid Caching Parameters: Sitekeys and callbacks can change—extract them on each run.
-
Handle Timeouts: Set a solution wait limit (typically 60–120 seconds).
-
Use Residential Proxies: Improves solving success rates for Google services.
-
Test with Google's Test Keys: Debug token injection logic without consuming balance.
Code Examples for Other Languages
Official 2Captcha libraries are available for:
Useful Links
- reCAPTCHA v2 API Documentation: https://2captcha.com/api-docs/recaptcha-v2
- Testing Demo Page: https://2captcha.com/demo/recaptcha-v2
- findRecaptchaClients Script: https://2captcha.com/h/recaptcha-v2-callback
- Code Examples on GitHub: https://github.com/2captcha
- Support Center: https://2captcha.com/support/tickets/new
Conclusion
Bypassing reCAPTCHA v2 Invisible boils down to three key steps: accurately identifying CAPTCHA parameters (especially the callback function), submitting the task to the API with isInvisible: true, and correctly injecting the returned token by invoking the callback function.
Key Takeaways:
- Always set "isInvisible": true in your API request for the invisible version
- Locate and invoke the function specified in data-callback—without this, the site won't accept the token
- Use Google's test keys for debugging without consuming balance
- Synchronize User-Agent and cookies between your browser session and API requests
Following these guidelines will enable you to reliably integrate reCAPTCHA v2 Invisible bypassing into your automation projects.