Sorry if this question is repeated. I always try to get the answer before asking here, and this time I did not find it (suddenly I did not use the correct key words, maybe for lack of knowledge, but whatever).
CONTEXT
I work in a company where I have restricted access to the internet. To access some sites, proxy is used.
In this company, from time to time I create small software to automate some demands. And for some of these demands, you need to access specific websites.
I use a lot of VBA to do this, since whoever takes advantage of these requests a report of what was done, and making the software in Excel is very convenient.
For these softwares that access websites, I often used VBA to control Internet Explorer so that it replicates the necessary actions. I never liked doing this, since some sites loaded content without making the browser show that it was busy.
Recently I've been studying the WinHTTP library, where I can make requests directly to the site I want and I get the HTML of the page, and I found GOOD better than using Internet Explorer.
I've done 2 programs that worked perfectly. The former accessed a site available only on the company intranet . The second accessed an external site, and I had to make the Proxy explicit to the WinHTTP object. That way it worked normal.
PROBLEM
The third program is being problematic. It has to access an external site too, but even with proxy I do not get the HTML page. The request returns me the 407 (proxy authentication required) error.
As in the second program that was done, was not this authentication requested?
I tried to use the .SetCredentials
command with my username and password, but nothing happens.
I remember the answer has the headers: "Proxy-Authenticate": "Negotiate" "Proxy-Authenticate": "Kerberos" "Proxy-Authenticate": "NTLM"
I also tried the same request from outside the company (home), and I received the html page normally, with status 200.
How do I make the program work inside the company?