Metadata-Version: 2.4
Name: selenium-proxy-auth
Version: 0.1.0
Summary: Authenticated proxies for Selenium + Chrome without selenium-wire. Generates a proxy-auth extension on the fly.
Author-email: JiBao Proxy <support@jibaoproxy.com>
License: MIT
Project-URL: Homepage, https://jibaoproxy.com
Project-URL: Source, https://github.com/jibaoproxyofficial-pixel/selenium-proxy-auth
Keywords: selenium,proxy,proxy-authentication,chrome,web-scraping,browser-automation,residential-proxy
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# selenium-proxy-auth

[![PyPI version](https://img.shields.io/pypi/v/selenium-proxy-auth.svg)](https://pypi.org/project/selenium-proxy-auth/)
[![Python versions](https://img.shields.io/pypi/pyversions/selenium-proxy-auth.svg)](https://pypi.org/project/selenium-proxy-auth/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Use an **authenticated (user:pass) proxy with Selenium + Chrome** — without selenium-wire. It generates a tiny proxy-auth extension on the fly and loads it, so Chrome never shows the native auth popup that Selenium can't click.

```bash
pip install selenium-proxy-auth
```

## The problem

Chrome's `--proxy-server` flag has nowhere to put a username and password. So with an authenticated proxy, Chrome throws a **native auth dialog** — which Selenium can't interact with — and every request hangs or 407s:

```python
# ❌ no place for credentials; Chrome shows a popup Selenium can't dismiss
opts.add_argument("--proxy-server=http://user:pass@gw.example.com:913")
```

The reliable fix is a small extension that sets `chrome.proxy` and answers `onAuthRequired` with your credentials. This package builds and loads it for you.

## Usage

```python
import shutil
from selenium import webdriver
from selenium_proxy_auth import add_proxy

opts = webdriver.ChromeOptions()
opts.add_argument("--headless=new")

ext = add_proxy(opts, "http://USERNAME:PASSWORD@us.jibaoproxy.com:913")

driver = webdriver.Chrome(options=opts)
try:
    driver.get("https://httpbin.org/ip")
    print(driver.find_element("tag name", "body").text)
finally:
    driver.quit()
    shutil.rmtree(ext, ignore_errors=True)   # clean up the generated extension
```

`add_proxy` returns the path to the generated extension directory so you can delete it afterwards. The extension contains your credentials in plaintext — it's written to a temp dir; don't commit it.

## How it works

- Manifest V3 extension with the `proxy`, `webRequest`, and `webRequestAuthProvider` permissions.
- A background service worker sets `chrome.proxy.settings` to your `host:port` and returns `authCredentials` from `onAuthRequired`.
- Loaded via `--load-extension`, so it works in headless `--headless=new`. (Old `--headless` does not load extensions; use `--headless=new`.)

Need just the files (e.g. for undetected-chromedriver)? Use `make_proxy_extension(url)` to get the directory and load it yourself.

## Rotating IPs

A rotating residential gateway hands out a new exit IP per connection from one URL — point `add_proxy` at the gateway and each fresh `webdriver.Chrome` gets a different IP. If you're still getting blocked after authenticating, the exit IP is the issue: datacenter ranges get scored as bots by ASN and [TLS fingerprint](https://jibaoproxy.com/blog/ja3-tls-fingerprint-detection-explained.html) before the page loads. We build [JiBao Proxy](https://jibaoproxy.com) for clean residential exits — 72M+ IPs, 200+ countries, sticky sessions. Works with any provider, though.

## Related

- [Selenium & Playwright proxy authentication, explained](https://jibaoproxy.com/blog/selenium-playwright-proxy-authentication.html)
- [AdsPower / Multilogin proxy setup](https://jibaoproxy.com/blog/adspower-multilogin-proxy-setup.html)
- [Bypassing DataDome & PerimeterX in 2026](https://jibaoproxy.com/blog/datadome-perimeterx-bypass-2026.html)

## License

MIT
