How open a url (a browser window) that need "http authentication" passing login and password in a transparent way? The legacy app in delphi need open a report in ".aspx" from Reporting Services.
Thanks, Celso
Use the Indy TidHTTP component as it can easily handle the authentication requirements. Drop the component on the form and:
IdHTTP1.Request.UserName := 'xxx';
IdHTTP1.Request.Password := 'xxx';
IdHTTP1.Get(x);
I believe that works for whatever Indy version that you might have.
You can use WinHTTP, check the IWinHttpRequest.SetCredentials
method
check this sample
uses
Variants,
SysUtils,
WinHttp_TLB;
Const
HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0;
Var
Http: IWinHttpRequest;
begin
try
Http := CoWinHttpRequest.Create;
try
Http.Open('GET', 'http://Foo.com/home', False);
Http.SetCredentials('AUser','APassword', HTTPREQUEST_SETCREDENTIALS_FOR_SERVER);
Http.Send(EmptyParam);
//Do your stuff
finally
Http:=nil;
end;
except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;
end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With