user508402
user508402

Reputation: 492

indy https GET - authentication

I am trying to make a HTTPS-get request work in order to load a webpage wich has the url starting with "https:". I am using Indy10 (5248) with delphi 7. I don't seem to be able to get the authorization right, even using the same name/password or domain\name/password that I use in a browser. All I get is the same server response as if in the browser I would cancel the authentication request.

Now there are several ways to supply name/pwd:

In addition there are options. Even though there's a finite number of combinations, I haven't been able yet to find one working for me. What is the correct way of doing this?

s := IdHTTP1.Get('https://qwerty.wur.nl');
Memo1.Lines.Add(Format('Response Code: %d', [IdHTTP1.ResponseCode]));
Memo1.Lines.Add(Format('Response Text: %s', [IdHTTP1.ResponseText]));

Memo1.Lines.Add(s);

Upvotes: 1

Views: 13364

Answers (2)

Remy Lebeau
Remy Lebeau

Reputation: 596256

The correct way to specify HTTP authentication credentials in TIdHTTP is to use the TIdHTTP.Request properties. That is where TIdHTTP looks for them when starting a new authenticated session. If the server rejects/challenges the authentication, the OnSelectAuthorization and OnAuthorization events are triggered to allow the app to select a different authentication scheme and/or supply different credentials, respectively.

As for the POST example, it is posting an HTML webform, such as you would see on a website's login page. The parameters are determined by analyzing the HTML that defines the webform, just like a webbrowser would do. Webform authentication has nothing to do with HTTP authentication. The two are not mutually exclusive, they can be used together if the server decides to.

Upvotes: 1

Wosi
Wosi

Reputation: 45243

You don't need proxy params. Set IdHTTP1.Request.BasicAuthentication instead:

IdHTTP1.Request.BasicAuthentication:= true;
IdHTTP1.Request.UserName := UserName;
IdHTTP1.Request.Password := Password;

Be aware that you need to prepare your application and IdHTTP1 for SSL as explained here: Delphi: idHttp+SSL and here TIdHTTP.Get EIdIOHandlerPropInvalid Error

Upvotes: 3

Related Questions