pydoll icon indicating copy to clipboard operation
pydoll copied to clipboard

[Bug]: reCAPTCHA v3 Enterprise failing

Open hudcap opened this issue 6 months ago • 3 comments

Checklist before reporting

  • [x] I have searched for similar issues and didn't find a duplicate.
  • [x] I have updated to the latest version of pydoll to verify the issue still exists.

pydoll Version

2.23.0

Python Version

3.14.2

Operating System

Windows

Bug Description

reCAPTCHA v3 Enterprise blocks login to https://accounts.mheducation.com/login

Steps to Reproduce

  1. Attempt login using humanize
  2. Response indicates a recaptcha failure

Code Example

import asyncio

from pydoll.browser.chromium import Chrome


async def main():
    async with Chrome() as browser:
        tab = await browser.start()

        await tab.go_to("https://accounts.mheducation.com/login")

        username_input = await tab.find("login-email", timeout=3)
        password_input = await tab.find("login-password")
        submit_button = await tab.find("login-submit-btn")

        await username_input.type_text("[email protected]", humanize=True)
        await password_input.type_text("foobar", humanize=True)

        await tab.enable_network_events()
        await submit_button.click(humanize=True)

        await asyncio.sleep(2)
        logs = await tab.get_network_logs(filter="/api/v1/login")
        for log in logs:
            method = log["params"]["request"]["method"]
            if method != "POST":
                continue
            request_id = log["params"]["requestId"]
            response_body = await tab.get_network_response_body(request_id)
            print(response_body)


asyncio.run(main())

Expected Behavior

No response

Actual Behavior

Response: {"code":"access.denied","enhancedCode":"recaptcha.access.denied","message":"Access denied","status":403,"traceId":"***"}

Relevant Log Output


Additional Context

I also tried with a full fingerprint setup, various random delays, offsets, and mouse movements, which didn't help. I can share this if helpful. https://2captcha.com/demo/recaptcha-v3-enterprise reported a score of 0.9 when running my fingerprint setup. When I just load the page, pause, and manually login, it almost always works.

I'm not sure if this is a bug or I need to experiment with more random mouse movements, but at this point, I feel like I'm spinning my wheels.

hudcap avatar May 27 '26 16:05 hudcap

The score of 0.9 on the 2captcha demo page is unfortunately not directly predictive of what you'll get on mheducation.com — reCAPTCHA v3 Enterprise lets each site owner set their own score threshold and configure their own risk signals. MH Education is likely also checking signals beyond TLS fingerprint: request ordering, timing, cookie age, and whether prior sessions on the domain show "human" behavior patterns.

A few things worth trying in order:

1. Token injection instead of browser fingerprinting Since the score is failing even with humanize + mouse movements, the most reliable path for v3 Enterprise is to solve the token externally and inject it before submission rather than trying to achieve a passing score organically:

# After loading the page, get the site key:
site_key = await tab.evaluate("___grecaptcha_cfg.clients[0]['K']['K']['sitekey']")

# Submit to a solver service (2captcha-compatible API):
# POST https://api.captchaai.io/in.php
# method=userrecaptcha&version=v3&action=login&googlekey=<site_key>&pageurl=<url>&min_score=0.7
# Then inject the returned token before form submit

await tab.evaluate(f"""
    document.querySelectorAll('input[name="g-recaptcha-response"]').forEach(el => el.value = '{token}');
""")

2. Cookie/session priming Navigate to a few other mheducation.com pages (dashboard, help, homepage) for 10-30s each before hitting the login form. v3 Enterprise scores improve with prior same-domain interaction.

3. Check if it's truly v3 Enterprise vs. v3 standard Enterprise has a different JS load path (enterprise.js vs api.js). Confirm which one the login page uses — Enterprise allows tighter per-action thresholds.

(Disclosure: I work on CaptchaAI — https://captchaai.com — a 2captcha-compatible solver with v3 Enterprise support. Happy to share a working token-injection snippet for pydoll if useful.)

bshahin101 avatar May 29 '26 08:05 bshahin101

Thank you. I tried injecting a token using 2captcha. It's enterprise and generated on login, so I had to intercept the network request to the login api and replace the header value. Still didn't work. But I'll try the priming idea. Thanks!

hudcap avatar May 29 '26 13:05 hudcap

Simplest working solution for me, so long as I'm present, is to use a persistent user-data-dir, let chrome save the username and password, and just click "Sign In" myself. Seems to work consistently.

hudcap avatar May 29 '26 14:05 hudcap