Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Support for authenticated proxies #29

Closed
andrewlinfoot opened this issue Jul 26, 2017 · 5 comments
Closed

Support for authenticated proxies #29

andrewlinfoot opened this issue Jul 26, 2017 · 5 comments

Comments

@andrewlinfoot
Copy link

Does this support authenticated proxies? Similar to how nightmarejs has the .authentication method

@joelgriffith
Copy link
Contributor

@bryan
Copy link

bryan commented Jul 28, 2017

Requested by Tim on Slack to post here regarding a use case for HTTP Basic Authentication - the popup that appears for credential login when htpasswd configured by a web server like Apache or NGINX.

Currently, I believe Selenium 3.4 has a working beta on it. Would be great if this was supported.

@jborden13
Copy link

@adieuadieu do you have an example of how this works with authenticated proxies? I'm setting the --proxy-server chrome flag (ip:port) and then adding Authorization and Proxy-Authorization headers (base64(user:pass)) using the setExtraHTTPHeaders. Has this functionality been confirmed?

@felixfbecker
Copy link
Contributor

felixfbecker commented Dec 14, 2017

Should be solved with #325 (v1.4.0)

@firecode9
Copy link

firecode9 commented Feb 28, 2018

For anyone still looking for a way to do so, take a look at: https://blog.apify.com/how-to-make-headless-chrome-and-puppeteer-use-a-proxy-server-with-authentication-249a21a79212. or in short:

const chromeLauncher = require('chrome-launcher');
const { Chromeless } = require('chromeless')
const proxyChain = require('proxy-chain');

async function run() {

  const oldProxyUrl = 'http://USER:PASS@PROXY_HOST_HERE:PROXY_PORT_HERE';
  const newProxyUrl = await proxyChain.anonymizeProxy(oldProxyUrl);

  const chrome = await chromeLauncher.launch({
    port: 9222,
    chromeFlags: [
      '--window-size=1200,800',
      '--disable-gpu',
      '--headless',
      `--proxy-server=${newProxyUrl}`
    ]
  });

  const chromeless = new Chromeless({
    launchChrome: false
  });

  const screenshot = await chromeless
    .goto('https://google.com')
    
    .type('chromeless', 'input[name="q"]')
    .press(13)
    .wait('#searchResultsTbl')
    .screenshot()

  console.log(screenshot) // prints local file path or S3 url

  await chromeless.end()
}

run().catch(console.error.bind(console))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants