Comments (5)
If you want windows authentication and SSO then you might try this hack by changing :
Public Function PrepareHttpRequest(Request As RestRequest, TimeoutMS As Long, _
Optional UseAsync As Boolean = False) As Object
Dim http As Object
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
'This is the options:
'typedef enum WinHttpRequestAutoLogonPolicy {
' AutoLogonPolicy_Always = 0,
' AutoLogonPolicy_OnlyIfBypassProxy = 1,
' AutoLogonPolicy_Never = 2
' } WinHttpRequestAutoLogonPolicy;
http.SetAutoLogonPolicy 0
' Set timeouts
http.setTimeouts TimeoutMS, TimeoutMS, TimeoutMS, TimeoutMS
' Pass http to request and setup onreadystatechange
If UseAsync Then
Set Request.HttpRequest = http
http.onreadystatechange = Request
End If
Set PrepareHttpRequest = http
End Function
Potential unexpected side effects, well might be so haven't tested all cases.
It worked for me to do post / get towards an internal WCF with windows security. That said the conclusion is that your mileage might vary...
(Added code formatting)
from vba-web.
Hi @sravikiran, I'm not too familiar with Windows authentication, but I think the following should help. First, I would recommend checking out the wiki for details on implementing your own IAuthenticator. Using that approach, I would skip the Setup step, use the standard HttpOpen
, and define the following BeforeExecute
:
Private Function GenerateToken(Username As String) As String
' Your specific details for generating a token
GenerateToken = Username
End Function
Private Sub IAuthenticator_BeforeExecute(Request As RestRequest)
Request.AddHeader "Authorization", GenerateToken(Application.UserName)
End Sub
Reading more about "Windows integrated authentication" (NTLM) (this Stack Overflow question has a good breakdown) it seems much more complicated than simply creating a token based on the user id, is that what you are trying to implement? If so, I can look into creating a Windows Integrated Authenticator.
from vba-web.
Hi @timhall ,
Sorry for the slow response. Thanks for the insights. I wasn't aware that the windows authenticator sends messages with the request to the server to get the user authenticated. When I hit the get endpoints of the REST API using a browser, the browser sets the Authorization header value, I thought it is the authorization token.
It will be great if you can create an authenticator for Windows Integrated Authentication, as it will be useful for anyone looking for what I asked here. Thanks.
from vba-web.
Hi,
Not sure what kind of Windows authentication you need, but I have an internal site that uses Windows Auth.
If you need a manual/specific set of credentials used, then these can be passed on the open call, as seen here:
http://zanstra.home.xs4all.nl/inTec/ServerXMLHTTP.htm
Thus a custom Windows version of IAuthenticator could be created.
What I need is to use the current users credentials, which happens auto-magically if you use XMLHTTP instead of ServerXMLHTTP. So I switched the PrepareHttpRequest function to create one of those instead and that worked without specifying credentials anywhere.
It does not seem to have a setTimeouts method (at least not with the same name).
Any reason why ServerXMLHTTP is used, as opposed to the XMLHTTP class?
from vba-web.
@opoani Cool! I was just about to write this off, I'll see if I can integrate that in v4.0.0
from vba-web.
Related Issues (20)
- On Mac Japanese, the Json double quote Escape backslash \ (0x5c) is converted to 0x80 HOT 1
- Code VBA inside any text editor thanks to VBA-Web
- Can't install this tool HOT 2
- Excel 2016 For Mac 64-Bit Update - 'Internal Errors'
- Run time error 10001: error parsing json expecting "" or ''' HOT 13
- Installation no longer works since the office update HOT 2
- Not sure how to proceed with HttpBasicAuthenticator HOT 1
- Get Json from Google-Drive work on Windows but not on Mac HOT 1
- Update GitHub language breakdown HOT 1
- AWS Authentication
- Uploading a PDF to SharePoint REST API using an ADODB stream HOT 1
- Authenticator for Zoho Creator API
- Calling POST API Content-Type-application/json and getting error "Cannot deserialize the current JSON object" HOT 2
- 保存 HOT 1
- POST API to Verint, the connection is not getting authorised HOT 1
- Excel VBA
- Error with OAuth1.0 Authentication HOT 1
- あ
- Saving Image Response To A PNG File In Mac
- Better version that reads the object properties and makes into a table with headers: HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vba-web.