Call await page.authenticate({ username, password }) before navigating to the protected page, then capture it with page.screenshot(). Puppeteer documents this API for HTTP authentication; it enables request interception behind the scenes, which may affect performance.
Capture an authenticated page with Puppeteer
Install Puppeteer in your Node.js project if it is not already installed, then provide the credentials before page.goto(). This example reads secrets from environment variables rather than embedding them in source code:
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.authenticate({
username: process.env.BASIC_AUTH_USERNAME,
password: process.env.BASIC_AUTH_PASSWORD,
});
await page.goto('https://example.com/protected', {
waitUntil: 'networkidle2',
});
await page.screenshot({ path: 'screenshot.png', fullPage: true });
} finally {
await browser.close();
}
Replace the example URL with the protected page. Set BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD in the environment where the script runs. Puppeteer does not require environment variables; they are a practical way to keep credentials out of checked-in code.
Why authentication must come before navigation
page.authenticate() supplies credentials for HTTP authentication challenges. Call it before navigating so Puppeteer can respond when the protected resource requests credentials. The method accepts a credentials object or null; passing null disables authentication.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitches#1 Best Overall
- 【Strong Adsorption】The inspiration of the silicone phone suction case comes from the adhesive force of the octopus. Each suction cup phone mount is 3.15 inches long and 2.17 inches wide, with 24 independent suction cups providing a stronger and more stable suction force, so you don't have to worry about your phone falling during use.
- 【Back of Phone Suction Grip】Remove the adhesive film on the phone suction cup and stick it on the phone case. You can then fix the phone on any smooth surface, which is very convenient. (The phone suction cup cannot be removed and reused after being attached to the phone case. It is recommended to attach it to a regular phone case, not a valuable one.)
- 【Widely Used】Our non-slip silicone phone sticky grip mount attaches to almost any flat phone case and make it compatible with common mobile phones such as iPhone and Android.You can shoot, watch videos or video calls in the kitchen, gym, dance studio, bathroom and other places.
- 【Capture the Wonderful Picture】Whether you are a TikTok creator or just like to share videos and photos, this phone suction cup can help you hands-free capture wonderful videos and photos for sharing with friends.
- 【Note】You can fix the phone suction cup on a smooth surface such as a mirror or glass. If necessary, wipe the suction cup with a damp cloth to obtain stronger suction. Before releasing your hand, make sure the phone is firmly fixed. (Not applicable to rough walls, wooden surfaces, and other uneven surfaces)
Puppeteer’s current API page identifies version 25.12.0 and notes that authentication enables request interception internally, which might affect performance. The documentation does not quantify that impact. Puppeteer Page.authenticate() API
Choose when the page is ready
The example uses waitUntil: 'networkidle2', which is one possible navigation wait condition—not a guarantee that every page is visually complete. Choose a readiness condition that fits the site; pages with continuous network activity or delayed rendering may need a different strategy.
Rank #2
- SUPERIOR COMFORT — Unlike traditional circular ear buds, the design of EarPods is defined by the geometry of the ear. Which makes them more comfortable for more people than any other ear bud–style headphones.
- HIGH-QUALITY AUDIO — The speakers inside EarPods have been engineered to maximize sound output and minimize sound loss, which means you get high-quality audio.
- BUILT-IN REMOTE — EarPods with USB-C plug also include a built-in remote that lets you adjust the volume, control the playback of music and video, and answer or end calls with a pinch of the cord.
- COMPATIBILITY — Works with all devices that have a USB-C port.
- INTEGRATED MICROPHONE — A built-in microphone precisely captures your voice while you’re on the phone, taking a FaceTime call, or summoning Siri — so you’re always heard loud and clear.
Choose screenshot scope and output
Puppeteer’s page.screenshot() supports saving to a path and options such as full-page capture, clipping, output type, and encoding. Full-page capture defaults to false, and the default output type is PNG. When saving to a path, the file extension can determine the image type. See the ScreenshotOptions interface.
- Viewport: Omit
fullPageto capture the currently visible viewport. - Full document: Set
fullPage: trueto request a full-page image, as in the example. - Specific region: Use
clipwhen the screenshot should cover a defined rectangle rather than the whole viewport or document. - Specific element: Locate an element and use its
ElementHandle.screenshot()method. Puppeteer’s screenshot guide describes this option. - Format or returned data: Select the screenshot type or encoding when needed; otherwise, saving to a path with a suitable extension is straightforward.
The official Puppeteer screenshots guide demonstrates the general launch, navigate, capture, and close sequence.
Rank #3
- Secure Hold: Our PopSockets adhesive phone grip gives your cell phone a secure, comfortable hold in hand to help prevent drops while texting, taking photos, or scrolling on the go. Designed to stick firmly to most phone cases and devices.
- Hands-Free Made Easy: Easily turn your PopSocket into a phone stand to prop up your phone anywhere, perfect for watching videos, video calls, or following recipes. A must-have phone holder that keeps your device secure and ready for anything.
- Compatibility: Works with all phones, tablets, and Kindles. Sticks best to smooth, hard plastic cases and may not adhere to silicone or textured cases. Easily swap your PopTop to change up your style.
- Black PopSockets: Simple, refined, and endlessly versatile. A timeless essential for any phone.
- Travel Must-Have for People On the Go: A must-have travel accessory for flights, flying, airports, air travel, airplanes, planes, international trips, cruises, and long travel days. Key gadget for your airport haul, travel accessories and must-haves.
Security and deployment considerations
- Do not put real credentials in published examples, screenshots, command output, or source files committed to version control. Use environment variables or a secret store appropriate to your deployment.
- HTTP authentication is not the same as submitting a username and password into a website’s HTML login form. This method addresses HTTP authentication challenges.
- Puppeteer documents HTTP authentication generally. The Chrome DevTools Protocol describes challenges such as HTTP 401 or 407 and includes Basic and Digest schemes, but that protocol context does not guarantee identical behavior for every browser, Puppeteer version, proxy, server challenge, or redirect sequence. Confirm behavior in the deployment you use. Chrome DevTools Protocol Fetch domain
- Use
try/finallyto close the browser even if navigation or capture fails. This prevents a failed run from leaving the browser process open.
Troubleshooting
The screenshot shows an authentication error
Check that the URL is protected by HTTP authentication, not a page-level login form, and verify that the credentials are valid for the server’s challenge. The Puppeteer API documentation does not provide a complete diagnostic matrix for incorrect credentials or multi-hop redirects.
Navigation times out or never reaches the selected wait condition
Review whether the page keeps network requests active and whether networkidle2 is appropriate for it. A readiness condition is a navigation signal, not proof that all application content has finished rendering.
Rank #4
- [360 ° Flexible Rotation Design] Comes with a rotatable lanyard ring that supports 360 ° free rotation, effectively solving the problem of twisted and tangled lanyards
- [Wide compatibility] The ultra-thin 0.02-inch design does not block the charging port at all, and both wired and wireless charging can be used directly without removing the pad. Compatible with most smartphones such as iPhone, compatible with various wristbands, lanyards, crossbody straps, and keychains
- [Durable and Portable Material] Premium rust-resistant stainless steel material with good flexibility, which not only avoids scratching the phone case, but also has excellent anti rust and anti fading performance
- [Multi scenario Practical] Paired with a lanyard or wristband, hands-free use can be achieved. The phone is within reach and not easily dropped, ideal for daily commuting and outdoor activities. Suitable for full coverage phone cases, does not support half coverage phone cases
- [Quality Service] If you find any damage or other issues with the product upon receipt, please contact us immediately. We will handle it quickly
The capture is missing content or has the wrong dimensions
Check whether you need a viewport screenshot, fullPage: true, a clip rectangle, or an element screenshot. Also verify the output type and path. Full-page capture is not enabled by default.
The script leaves browser processes behind after a failure
Ensure browser shutdown is in a finally block. The example uses this pattern so it runs after either a successful capture or an exception.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchBest Value
- 【PKYAA Double Sided Silicone Suction Phone Case Mount】PKYAA With Double Sided 40 Strong and Reliable individual suction cups, PKYAA provides a thicken and upgraded universal silicon suction mount for your phone.
- 【Friendly to Content Creators】If you are a content creator or an online influencer, you can create videos anywhere with this suction mount completely hands free with this silicone cell phone mount for cases.
- 【HANDS-FREE & Adhere to Mirrors】This Double Sided silicone suction phone case mount allows you to stick your phone to the mirror easily. No longer holding your phone in one hand to watch video tutorials while making up.
- 【Strong Grip on the Smooth Surface】You can easily hang your phone anywhere with a smooth surface. All you do is you clean off your phone and smooth surface. It is STURDY and it not only sticks to mirrors, it also sticks to windows, it sticks to refrigerators, tiles and other clean, flat surfaces.
- 【Press Down Firmly Every 30 Minutes】Use your palm or fingers to press the phone down firmly and check it's secure before letting go. Apply even pressure for a few seconds to allow the suction cup to adhere properly. To maintain the grip and prevent accidental falls, it's a good practice to periodically reapply pressure to the suction cup.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. It can handle a URL in one GET request, so you do not need to launch and manage Puppeteer for this capture. This example uses the documented endpoint and parameters; see the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/protected -o shot.webp
- Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; each cleanup step can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents and MCP clients. - The Free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Frequently Asked Questions
Does Puppeteer’s authenticate method work for a normal website login form?
No. It supplies credentials for HTTP authentication challenges; it does not fill in a website’s HTML login form.
Can I turn off HTTP authentication after setting it?
Yes. Puppeteer documents that passing null to page.authenticate() disables authentication.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

