Skip to content
solvepass

Puppeteer + Solvepass

Use the same task flow with Puppeteer and pass the token into the page or a form callback.

TypeScriptChrome-first automation and scraping pipelines.
solvepass-puppeteer.tstypescript
import puppeteer from "puppeteer";

const key = process.env.SOLVEPASS_KEY;
const headers = {
  Authorization: `Bearer ${key}`,
  "Content-Type": "application/json",
};

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://example.com/login");

const task = await fetch("https://api.solvepass.com/v1/tasks", {
  method: "POST",
  headers,
  body: JSON.stringify({
    type: "cloudflare_turnstile",
    sitekey: "0x4...",
    pageurl: page.url(),
  }),
}).then((res) => res.json());

let token;
for (;;) {
  const data = await fetch(
    `https://api.solvepass.com/v1/tasks/${task.id}`,
    { headers }
  ).then((res) => res.json());

  if (data.status === "completed") {
    token = data.solution.token;
    break;
  }
  if (data.status === "failed") throw new Error(data.error.code);
  await new Promise((resolve) => setTimeout(resolve, 1000));
}

await page.evaluate((value) => {
  const field = document.querySelector(
    "input[name='cf-turnstile-response']"
  );
  if (field) field.value = value;
}, token);

await browser.close();

What to check

  • Turnstile tokens go in cf-turnstile-response, not g-recaptcha-response.
  • If the page uses a callback, invoke it with the token instead of setting the field.
  • Puppeteer's page URL can change after a client-side redirect; read it after the challenge appears.

The same three steps

  1. 01Create a task with the type, sitekey, and page URL.
  2. 02Poll the task or wait for a signed webhook.
  3. 03Use the token, or apply the clearance cookies with the same proxy and user agent.

Other integrations