#1 2019-01-30 13:40:15

egold2005
Member
Registered: 2019-01-28
Posts: 16

Basic authorization with THttpClientSocket

I am new to this stuff and trying to pass login/password.

Should i do that before calling .Open?

    vUsername := 'Dispatch';
    vPassword := '1234';
    vLogin := vUsername + ':' + vPassword;

    vBase64 := TBase64Encoding.Create;
    try
      vAuth := 'Authorization: Basic ' + vBase64.Encode(vLogin);
    finally
      vBase64.Free
    end;

    FClient.HeaderAdd(vAuth);
    FClient.Open('127.0.0.1', '8095');

    result := FClient.Get(vURL);

Thanx alot.

Offline

#2 2019-01-31 11:16:43

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Basic authorization with THttpClientSocket

Why are you not using the default available authentication classes?

Last edited by pvn0 (2019-01-31 11:16:51)

Offline

#3 2019-01-31 11:29:10

egold2005
Member
Registered: 2019-01-28
Posts: 16

Re: Basic authorization with THttpClientSocket

pvn0 wrote:

Why are you not using the default available authentication classes?

Because i have no idea about the framework yet and the classes it offers.

What classes should i use? Any sample code available?

Thanx.

Offline

#4 2019-01-31 11:34:39

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Basic authorization with THttpClientSocket

Read the docs here : https://synopse.info/files/html/Synopse … 01.18.html.

After that you can go through the examples in the

SQLite3\Samples folder

Everything you need is described in the docs.

Last edited by pvn0 (2019-01-31 11:35:07)

Offline

#5 2019-02-04 08:41:55

egold2005
Member
Registered: 2019-01-28
Posts: 16

Re: Basic authorization with THttpClientSocket

I can not find any references to THttpClientSocket, neither in documentation nor samples.

What is the proper flow of method calls?

Should i use .Open constructor to specify the IP and port of the server and then use .Get and pass auth?

I end up with 505 error and i now see this is being raised inside THttpClientSocket.Request method.

Offline

#6 2019-02-04 09:32:15

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Basic authorization with THttpClientSocket

If you're only interested in client-server side of mORmot then you can start reading here 11. Client-Server process, specifically I imagine you are interested in 11.4. Network and Internet access via HTTP where you can pick server/client classes based on your preference.

Read 21. Security about authentication. I strongly suggest you use the built-in framework authentication instead of rolling your own.

Offline

Board footer

Powered by FluxBB