Selenium, Web Proxy and HTTP Basic Auth

Problem Statement:
Please offer a solution for basic authentication · Issue #6644 · SeleniumHQ/selenium

Install Firefox version 66.0.5 from here -
Why v66.0.5 specifically? Because it’s the latest version of Firefox where authentication alert 
handling would work. If you’re using a Linux box then you also need to run the “dpkg configure” 
command to install the package successfully. Once everything is done, please make sure the 
version of Firefox you just downloaded/installed is correct by running the “firefox --version” 

Let’s define the firefox driver now:
     proxy_host = ''
     proxy_port = ''

    def create_firefox_driver(user_agent = False):
    cap = DesiredCapabilities().FIREFOX

    options = Options()
    options.headless = True

    profile = webdriver.FirefoxProfile()
    if user_agent:
    profile.set_preference("general.useragent.override", user_agent) 
    # if you want to pass useragent
    profile.set_preference("network.proxy.type", 1)
    profile.set_preference("network.proxy.http", proxy_host)
    profile.set_preference("network.proxy.http_port", int(proxy_port))
    profile.set_preference('network.proxy.no_proxies_on', 'localhost,')
    driver = webdriver.Firefox(capabilities=cap,
    return driver

Now, let’s use the function in our code - 
    driver = create_firefox_driver()

Above code will prompt for the username/ password. 
Since, we typically want the entire process to be automated, we will enter the credentials from
within the code: 
    keyToSend = "<username>\ue004<password>"
    alert_window = driver.switch_to.alert

Try running with options.headless = False to see everything runs fine. This should work and you should
see the requests being made through the proxy server. Check on proxy dashboard (if you’ve bought
one and you got dashboard access to it)

Google Chrome
If you can/want to use Google Chrome then follow this tutorial 
However it doesn’t work with headless browsers as Chrome doesn’t support extensions in headless mode. 
Here’s what Google developer says -