0

I'm trying to use an authenticated proxy with seleniumbase (I'm using python) while running the browser in undetected Chrome (uc=True). However, despite trying multiple approaches, I'm unable to get the proxy authentication to work correctly. The prompt just keep comming up very time.

Here is my current setup:

chrome_options = {
    "headless": False,
    "uc": True,
    "incognito": True
}
chrome_options["proxy"] = f"{username}:{password}@{ip}:{port}"


# Initialize the driver with authenticated proxy
driver = Driver(**chrome_options)

try:
    # Open the target website
    driver.get("https://ipinfo.io/json")
    print("Current IP info:", driver.page_source)
    sleep(10)
finally:
    # Quit the driver
    driver.quit()

✅ What I’ve Tried So Far:

  1. Passing the proxy with credentials directly in the "proxy" key as shown above — doesn’t seem to be picked up properly.
  2. I tried to use this package from python https://pypi.org/project/selenium-authenticated-proxy/ but it doesn't work either
  3. I'ved tried this method of creating a new extension running in the background
manifest_json = """
{
    "version": "1.0.0",
    "manifest_version": 2,
    "name": "Chrome Proxy",
    "permissions": [
        "proxy",
        "tabs",
        "unlimitedStorage",
        "storage",
        "<all_urls>",
        "webRequest",
        "webRequestBlocking"
    ],
    "background": {
        "scripts": ["background.js"]
    },
    "minimum_chrome_version":"22.0.0"
}
"""
 
background_js = """
var config = {
        mode: "fixed_servers",
        rules: {
          singleProxy: {
            scheme: "http",
            host: "%s",
            port: parseInt(%s)
          },
          bypassList: ["localhost"]
        }
      };
 
chrome.proxy.settings.set({value: config, scope: "regular"}, function() {});
 
function callbackFn(details) {
    return {
        authCredentials: {
            username: "%s",
            password: "%s"
        }
    };
}
 
chrome.webRequest.onAuthRequired.addListener(
            callbackFn,
            {urls: ["<all_urls>"]},
            ['blocking']
);
""" % (PROXY_HOST, PROXY_PORT, PROXY_USER, PROXY_PASS)
 
 
def get_chromedriver(use_proxy=False, user_agent=None):
    path = os.path.dirname(os.path.abspath(__file__))
    chrome_options = webdriver.ChromeOptions()
    if use_proxy:
        pluginfile = 'proxy_auth_plugin.zip'
 
        with zipfile.ZipFile(pluginfile, 'w') as zp:
            zp.writestr("manifest.json", manifest_json)
            zp.writestr("background.js", background_js)
        chrome_options.add_extension(pluginfile)
    if user_agent:
        chrome_options.add_argument('--user-agent=%s' % user_agent)
    driver = webdriver.Chrome(
        os.path.join(path, 'chromedriver'),
        chrome_options=chrome_options)
    return driver 

👉🏻 Doesn't work 🥲

4. I'ved search all the solution on github but nothing seem to work stably

I need some help 🥲

1
  • I am also having the same problem. I have updated seleniumbase but still unable to login proxy. Has anyone ever solved this problem? I need your help Commented Nov 6 at 10:28

2 Answers 2

1

Though it's a bit late, I'm leaving this reply because I experienced the exact same issue as you.
I tried many different approaches, but in the end, upgrading SeleniumBase resolved everything.
That's all.

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

If you're using SeleniumBase UC Mode with Chrome 142 or newer, proxy auth is set after CDP Mode is activated:

from seleniumbase import SB

with SB(uc=True, proxy="user:pass@ip:port") as sb:
    url = "https://api.ipify.org"
    sb.activate_cdp_mode(url)
    print("Full IP from ipify:")
    print(sb.get_page_source())

Before Chrome 142, proxy auth could be set via Chrome extension, but Chrome 142 completely removed the --load-extension option, (and the workaround, which was --disable-features=DisableLoadExtensionCommandLineSwitch), so now, the auth is set via CDP, which happens when SeleniumBase CDP Mode is activated.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.