I want to interact with the REST API of a website (in EXCEL VBA) that requires authentication using either a digital certificate (file .PFX) (NTLM authentication) or using Windows domain authentication (Kerberos & Negotiate Authentication). The latter is preferable, but I also do not know how to do this, and I was hoping that someone could share code on how to perform any of these authentications. I can not use other authentication methods (for example, basic), because they are not supported.
I am currently using VBA-Web ( github:VBA-tools:VBA-Web) and I managed to interact with the API, but in a very strange way. I monitored network calls from Chrome to the site and noticed that it adds cookies to the header of each call. Therefore, in my queries, I add:
webrequest.SetHeader "Cookie", "server.com.au=35558896564.55846.54545; SDASESSION=AQISFCwMasdffczd6afASFVHfgfgsdf%2BG35FsE%3D%40AAJTSwAJSDFSDTkMw%3D%3D%23; amlbcookie=07; JSESSIONID=000f:19pcqj2d1; server2.com.au=484566584.454584.41545"
However, this is clearly annoying and not very user-friendly - since I have to look for cookies every time I want to use my Excel VBA code.
Also, after tracking the network authentication calls in Chrome, I noticed that it goes through various redirects, collecting all cookies as they are redirected. During one specific call, it performs authentication "negotiate".
VBA-Web seems to be based on WinHTTP, so I looked around, and I was really lost in how to interact with WinHTTP(or WinINet, etc.) to perform this authentication. I looked at the setCredentials Link method , but I'm not sure what the username and password for NTLM or Negotiate will be?
As an alternative, I tried using a digital certificate instead, but since I have a PFX file, I have no idea how to use it directly. I saw the link , but I'm not quite sure where my certificate is stored after installing PFX. I choose Personal during installation, does this mean in LOCAL_MACHINE \ Personal? More importantly, I don’t know the name of the item.
Microsoft C++, JScript, .
, cookie, . Excel VBA?
.. , . . , , , . -, , .