0
Answered
Regan 3 months ago in Crawlera • updated by Nestor Toledo Koplin (Support Engineer) 2 months ago 1

I get the following error when trying to access an ssl website through the proxy in C#: The remote server returned an error: (407) Proxy Authentication Required.


I have installed the certificate and tried the two following code methods below:


1.

var key = _scrapingApiKey;
var myProxy = new WebProxy("http://proxy.crawlera.com:8010");

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

vvar encodedApiKey = Base64Encode(key);
request.Headers.Add("Proxy-Authorization", "Basic " + encodedApiKey);

request.Proxy = myProxy;
request.PreAuthenticate = true;

WebResponse response = request.GetResponse();


2.

var myProxy = new WebProxy("http://proxy.crawlera.com:8010");

myProxy.Credentials = new NetworkCredential(_scrapingApiKey, "");

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

request.Proxy = myProxy;

request.PreAuthenticate = true;

WebResponse response = request.GetResponse();


What is the correct way to make the proxy work when accessing SSL websites?

Answer

Answer
Answered

Hello,


The top code should work, but make sure to include the ":" after the APIKey.

Answer
Answered

Hello,


The top code should work, but make sure to include the ":" after the APIKey.