Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Add http_credentials to browser context.

Bartlomiej Wietrak4633eb5e1402
diff --git a/browser_use/browser/context.py b/browser_use/browser/context.py
index 44b7595d5..5eb802317 100644
--- a/browser_use/browser/context.py
+++ b/browser_use/browser/context.py
@@ -107,6 +107,10 @@ class BrowserContextConfig:
include_dynamic_attributes: bool = True
Include dynamic attributes in the CSS selector. If you want to reuse the css_selectors, it might be better to set this to False.
+
+ http_credentials: None
+ Dictionary with HTTP authentication credentials, e.g.
+ {"username": "bill", "password": "pa55w0rd"}
"""
cookies_file: str | None = None
@@ -132,6 +136,7 @@ class BrowserContextConfig:
viewport_expansion: int = 500
allowed_domains: list[str] | None = None
include_dynamic_attributes: bool = True
+ http_credentials: dict[str, str] | None = None
_force_keep_context_alive: bool = False
@@ -326,6 +331,7 @@ class BrowserContext:
record_video_dir=self.config.save_recording_path,
record_video_size=self.config.browser_window_size,
locale=self.config.locale,
+ http_credentials=self.config.http_credentials,
)
if self.config.trace_path: