Call await page.authenticate({ username, password }) before navigating to a page protected by HTTP authentication. The method configures credentials for that Puppeteer Page; it does not fill in an ordinary website login form.
Set HTTP authentication credentials before navigation
Page.authenticate() accepts a credentials object with string properties named username and password. Await the call before navigating to the protected URL:
const { browser } = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.authenticate({
username: 'user',
password: 'pass',
});
await page.goto('https://example.com/protected');
// Continue with page inspection or other work here.
} finally {
await browser.close();
}
})();
Replace the example credentials and URL with your own. This is the documented API shape; it does not establish that those example credentials work against a live site. The method returns a Promise<void>, so use await to complete the setup before continuing.
What this method handles—and what it does not
HTTP authentication challenges
Puppeteer documents Page.authenticate(credentials) as providing credentials for HTTP authentication. It is a Page-level setting, not a browser-wide configuration.
#1 Best Overall
HTML login forms
A web page that displays username and password fields in its HTML is an application login form, not necessarily an HTTP authentication challenge. The API documentation does not establish that page.authenticate() fills or submits such a form. For a form-based flow, interact with the page’s form controls using the application’s documented login process instead.
Performance and request interception
Puppeteer’s Page API documentation says request interception is enabled behind the scenes to implement authentication and warns that this might affect performance. It does not quantify the impact, so there is no documented amount to apply as a general estimate. If performance matters, measure your own workload with and without authentication rather than assuming a specific slowdown.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Proxy authentication and separate credentials
page.authenticate() can be used for HTTP authentication challenges, including proxy authentication. A supplementary Puppeteer guide notes a limitation: one call cannot express different credential pairs for a proxy challenge and a website challenge at the same time. Its suggested architecture is to have a local proxy handle upstream proxy credentials, leaving page.authenticate() available for website authentication. This is practitioner guidance, not an official Puppeteer guarantee.
Disable authentication
Pass null to turn off authentication for the Page:
await page.authenticate(null);
Troubleshooting
- The protected page still rejects access: Confirm that the server is issuing an HTTP authentication challenge and that the username and password are correct. This method does not establish a session by filling an HTML login form.
- The page navigates before authentication is configured: Await
page.authenticate(...)before callingpage.goto()on the protected resource. - Proxy and site credentials conflict: One credentials pair cannot represent separate credentials for both challenges. Consider handling upstream proxy authentication in a local proxy, as described in the supplementary guide.
- Performance changes after enabling authentication: Request interception is part of the documented implementation and may affect performance, but Puppeteer publishes no measurement for the impact. Compare timings in the environment and workload that matter to you.
Or skip the browser setup
For capturing a page as an image, ScreenshotNeo offers a one-request screenshot API. It is a screenshot service, not a replacement for Puppeteer’s HTTP authentication setup; the example below does not pass HTTP-auth credentials.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #3
See the ScreenshotNeo API documentation for request options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/protected -o shot.webp
ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. Its MCP server provides screenshot tools for AI agents, and its free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. See ScreenshotNeo for service details.
Sign up for 1,000 free screenshots a month with no card.
Quick Recap
Best Value
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
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.




