Integrations
Browser automation: Playwright and Puppeteer
Configure proxy authentication for headless Chromium, and use sticky sessions to keep a login intact across a multi-step flow.
Headless browsers authenticate to a proxy differently than curl or an HTTP
client library: the username and password are passed as separate fields, not
embedded in a single URL. The username field is still the full login string,
your opaque username plus whatever _loc_<CODE> and _sticky suffixes you
want, exactly as described in
Rotating vs sticky sessions and location targeting.
Browser proxy support is built around HTTP proxies with authentication,
that's the well-supported path for both tools below. Use the HTTP endpoint
(proxy.masklabs.io:8080) for browser automation.
Playwright
npm install -D playwright
import { chromium } from 'playwright'
const browser = await chromium.launch({
proxy: {
server: 'http://proxy.masklabs.io:8080',
username: 'mlabs_a1f9c3_sticky',
password: '<PASSWORD>',
},
})
const page = await browser.newPage()
await page.goto('https://ipinfo.io/json')
server is just protocol://host:port, the credential goes in username
and password, not in the URL. Chromium and Firefox also accept a proxy
option per browser context (browser.newContext({ proxy: {...} })), so you
can hand different tabs different credentials or _loc_ targets without
relaunching the browser.
Puppeteer
npm install puppeteer
import puppeteer from 'puppeteer'
const browser = await puppeteer.launch({
args: ['--proxy-server=proxy.masklabs.io:8080'],
})
const page = await browser.newPage()
await page.authenticate({
username: 'mlabs_a1f9c3_sticky',
password: '<PASSWORD>',
})
await page.goto('https://ipinfo.io/json')
Puppeteer sets the proxy at launch (as a Chromium flag) and authenticates it
per-page with page.authenticate, the username there is the same full
login string, suffixes included.
Sticky sessions for logins
A login or checkout flow that spans several page loads should stay on one
exit IP for the whole flow, or the target may see the session cookie arrive
from a different IP mid-flow and kill it. Use one _sticky credential for
that flow and keep the same login string for every request the browser
makes, don't mix a rotating credential into the middle of it.
_sticky pins for about 60 seconds (see
Rotating vs sticky sessions and location targeting
for the full mechanics); most login and checkout flows complete well inside
that window.
SOCKS5 in a browser
Stick to the HTTP endpoint for automation. Authenticated SOCKS5 proxies
aren't reliably supported by Chromium's built-in proxy client the way HTTP
proxy auth is, the HTTP gateway (:8080) gives you the same rotating,
sticky, and location suffixes with dependable auth support in both tools
above.