Pode
Pode copied to clipboard
Route with authentication via IIS
Hello,
I'm trying to have a route with authentication via IIS. When I run through an internet browser, I have no problem. However, when I run PowerShell I get the following error:
I don't know how to put the header for IIS. The end goal is to execute a request via AJAX.
Can you help me please ?
Thank you.
Cordially,
Thomas.
Hi Thomas,
you'll need to add the -UseDefaultCredentials
to Invoke-RestMethod / Invoke-WebRequest in order to use Windows Integrated Authentication from those Cmdlets.
I know I can do it that way, but the goal is to run the request on AJAX or other method than PowerShell. From what I understand, everything happens in the header... but I don't know how to build it.
Thx.
Basically you just need to tell the client that is requesting (in this case PowerShell) to use integrated authentication.
For Ajax you can do it this way for example:
$.ajax({
type: 'POST',
url: url,
xhrFields: {
withCredentials: true
},
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(requestdata),
success: function (data) {
console.log(data.ObjectID);
}
});
I will try, thanks for your help.
Did it work?
Hello,
Now I have an error:
Do you know how I can correct it?
thank you.
Cordially,
Thomas PEREZ.
Yes, you need to set the Access-Control-Allow-Origin
Header according to the URL you're accessing from. Are you hosting your JS Files at Pode or on another Webserver?
Closing this issue, if it's still a problem feel free to re-open.