SurSolver

BlogHeaders, User-Agent and TLS: Why Solved Tokens Get Rejected

Headers, User-Agent and TLS: Why Solved Tokens Get Rejected

· Updated · 8 min read

A solve returns ready and the target still answers 403 or "invalid captcha". Usually the site compares the request that carries the result with the session that earned it. This post lists what to keep constant, how to check each piece, and how to tell a bad cookie from a bad client.

What the target compares

Six things have to agree between the solve and the request that uses it:

  1. Exit IP. The same proxy for the block, the solve and the replay. See proxies for captcha solving.
  2. User agent. The exact string the solve used.
  3. Client Hints. sec-ch-ua and related headers agree with the user agent.
  4. Language. Accept-Language stays the same and fits the proxy's region.
  5. Cookies. The whole returned set, not one value.
  6. Handshake and header order. TLS, HTTP/2 and header order look like the browser the user agent claims to be.

Tokens such as reCAPTCHA's gRecaptchaResponse or Turnstile's token are single-use, so send them with the request the page makes immediately. Cookie results (cf_clearance, datadome, _px3, _vcrcs) live longer, and the types that require your proxy expect them replayed from the solve's exit IP with the task's user agent. The solver guides for Cloudflare Challenge and DataDome cover where each one goes. Cloudflare Challenge with Playwright runs the whole cf_clearance replay through one proxy.

Choose one user agent and keep it

Three rules cover most cases:

  • Every web task requires userAgent. Read your browser's navigator.userAgent or choose the identity your HTTP client can reproduce, then supply that value in the task. Native Android/iOS app tasks are exempt.
  • The supplied value stays fixed. Use the task's userAgent on the request that consumes the result, as the context user agent in browser automation or the User-Agent header of an HTTP client.
  • Results do not return userAgent. This applies to all web task types, including Altcha and GeeTest. Keep the same client identity from the request that triggered the check to the request that uses the result.

Kasada and Shape results add acceptLanguage to the same block. Send it as the Accept-Language header of the replay, so language joins the identity instead of being whatever your HTTP library defaults to.

A cookie result looks like this. The main cookie comes back under its own name, and cookies maps every returned cookie name to its value:

snippet.json
{
  "errorId": 0,
  "status": "ready",
  "solution": {
    "datadome": "C2BBnQ...",
    "cookies": {
      "datadome": "C2BBnQ...",
      "datadome_consent": "denied"
    }
  }
}

Parse it by splitting on newlines and parsing each line; set every cookie, not only the one you recognise, on a client that presents userAgent and exits through the solve's proxy.

Make Client Hints agree

Chromium also reports its identity through Client Hints. If a site reads sec-ch-ua and friends, a Chrome/155 user agent next to Client Hints brands for another version is a contradiction the site can see, so the two should name the same browser and the same major version.

The result has no Client Hints or userAgent key. Derive the major version from the userAgent you supplied in the task. In a browser you can read what your page reports. Run this in the DevTools console, or in your automation tool's evaluate call:

solve.js
JSON.stringify({
  userAgent: navigator.userAgent,
  brands: navigator.userAgentData ? navigator.userAgentData.brands : null,
  languages: navigator.languages,
});

The DevTools console on a page: one JSON.stringify line reporting the user agent, the userAgentData brands, mobile and the languages array

If you override the user agent in automation, run this afterwards. Whether your tool updates the hints along with the string depends on the tool and its version, so check rather than assume.

Keep language and region consistent

Use one Accept-Language value for the whole flow, and make navigator.languages agree with it in browser sessions. Kasada and Shape hand you the value to use — their solutions carry acceptLanguage, so set the header from the solution instead of inventing one. Match the language to the proxy's region where you can; a request that says one locale and exits from another is a mismatch a site can weigh. Whether a given target cares is testable with the isolation test below.

Header order and the TLS handshake

A plain HTTP library presents its own TLS and HTTP/2 characteristics, which differ from a real browser's, and it orders headers its own way. Some protections score those signals before a challenge ever renders; whether your target is one of them is a property of the site, and the isolation test at the end of this post is how you find out. A valid-looking result replayed from a client whose handshake differs from a browser's can be refused with the right cookie and the right user agent — that failure mode is why this section is about checking, not assuming.

You have two ways to close the gap: drive a real browser for the requests, or use an HTTP client that reproduces a browser handshake. Your HTTP library also chooses header order, and you should verify it.

This script prints the request line and headers exactly as they arrive. It shows HTTP/1.1 order only, so it will not reveal a TLS or HTTP/2 mismatch:

solve.py
from http.server import BaseHTTPRequestHandler, HTTPServer

HOST = '127.0.0.1'
PORT = 8081


class Echo(BaseHTTPRequestHandler):
    def do_GET(self) -> None:
        print(self.requestline)
        for name, value in self.headers.items():
            print(f'  {name}: {value}')
        self.send_response(204)
        self.end_headers()


HTTPServer((HOST, PORT), Echo).serve_forever()

Open http://127.0.0.1:8081/ in the browser, then send the same request from your client, and compare the two lists.

For the handshake, an HTTP client that impersonates a browser can reproduce a Chrome-like TLS presentation; curl_cffi is one such library. The user agent supplied in the task and the impersonated browser version should agree, so this helper picks the matching target and refuses to guess:

solve.py
import re

from curl_cffi.requests import BrowserType, Session

CHROME_MAJOR = re.compile(r'Chrome/(\d+)')
TARGET_NAME = re.compile(r'chrome(\d+)a?')


def impersonation_target(user_agent: str) -> str:
    match = CHROME_MAJOR.search(user_agent)
    if match is None:
        raise ValueError('the task user agent is not a Chrome user agent')
    wanted = int(match.group(1))
    for browser in BrowserType:
        found = TARGET_NAME.fullmatch(browser.value)
        if found and int(found.group(1)) == wanted:
            return browser.value
    raise ValueError(f'no installed impersonation target for Chrome {wanted}')


def replay(url: str, solution: dict, proxy: str, user_agent: str) -> int:
    cookies = dict(solution.get('cookies', {}))
    with Session(impersonate=impersonation_target(user_agent)) as session:
        response = session.get(
            url,
            headers={'User-Agent': user_agent},
            cookies=cookies,
            proxies={'http': proxy, 'https': proxy},
        )
    return response.status_code

If impersonation_target raises, send a different userAgent in the next task, one whose version your client can reproduce. Do not paper over it with a mismatched string.

Copy a request from DevTools without losing information

In the Network panel, "Copy as cURL" gives you header names and values as text. Running that command in curl uses curl's handshake, not Chrome's, so it can fail where the browser succeeds. That failure says nothing about the headers.

"Save all as HAR" stores request headers as a list in the order the browser sent them. Use it as the reference for what the browser sent, captured through the same proxy and with the same language.

When a replayed result is refused, isolate the half that fails. Browse the target in a real browser through the same proxy, copy a cookie that is currently passing, and send it from your client with the browser's user agent.

  • Still 403: the problem is your client. Fix the handshake, header order or Accept-Language first.
  • Passes: the client is fine, so swap in the cookie from the solve. If only that cookie fails, check IP and user agent against the solve.

Common failures

  • Your library's default User-Agent goes out instead of task.userAgent.
  • The user agent says Windows Chrome while Client Hints, or the platform your client reports, say something else.
  • Accept-Language defaults to your library's locale while the solve presented solution.acceptLanguage.
  • The proxy rotated between the solve and the replay.
  • Only cf_clearance, or only one entry of the returned cookies, is sent.
  • A token is held for later. Tokens are single-use and short-lived.
  • createTask refuses userAgent: send a nonblank printable-ASCII string of at most 512 characters. All web task types require it.

Isolate, then replay

Reuse the required userAgent input. DataDome returns its cookie value as datadome; Cloudflare Challenge returns cf_clearance, __cf_bm when present, and a cookies object. Kasada and Shape return acceptLanguage for the protected request. Follow each guide's replay contract. The proxies guide lists which types need your own proxy. If blocks continue after the replay is consistent, stop getting blocked while scraping covers the request-pattern side.

More articles