#1 2017-02-08 17:12:52

ep
Member
Registered: 2017-02-08
Posts: 4

Android rest client authentification

Hi All,

I'm trying to connect my FMX app created with Delphi XE7 to my Server mormot but i don't handle the basic authentification process...
The final goal is to store some values from the client in the session like the current version of the app to retrieve it when the client call a method (i think i need to define the service with sicPerSession to get the data from the CurrentServiceContext).

When i do SetUser on the client i have an error server-side : "Invalid TAuthSession.Create(TSQLREstRoutingRest, TSQLAuthUser)".
I tried with TSQLRestServerAuthenticationNone and Server := TSQLRestServerFullMemory.Create(Model, false); to check if i can connect without control access but i have the same message.
Any idea about what i'm doing wrong ?
I have the 1.18 version of the framework.

Thanks in advance.

PS : I checked the samples, but i didn't found a fmx client (crossplatform units) which call SetUser to login to a server.


here some code about :

// SERVER SIDE

procedure TMainDM.CreateUsers;
var
  lGrp:TSQLAuthGroup;
  lUser:TSQLAuthUSer;
begin
  lGrp := TSQLAuthGroup.Create;
  try
    if Server.Retrieve('Ident=User', lGrp) then
    begin
      lUser := TSQLAuthUser.Create;
      try
        lUser.LogonName := 'TEST';
        lUser.DisplayName := 'TEST';
        lUser.GroupRights := lGrp;
        lUser.PasswordPlain := '';
        lUser.Data := '';
        Server.AddOrUpdate(lUser, true);
      finally
        FreeAndNil(lUser);
      end;
    end;
  finally
    FreeAndNIl(lGrp);
  end;
end;

procedure TMainDM.DataModuleCreate(Sender: TObject);
begin
  // initialize a TObjectList-based database engine
  Model := TSQLModel.Create([TSQLAuthGroup, TSQLAuthUser]);
  Server := TSQLRestServerFullMemory.Create(Model, true);
  Server.CreateMissingTables;
  Server.AuthenticationRegister(TSQLRestServerAuthenticationDefault);
  CreateUsers;
  // launch the HTTP server
  HTTPServer := TSQLHttpServer.Create('7277',[Server],'+',useHttpSocket);
  HTTPServer.AccessControlAllowOrigin := '*'; // for AJAX requests to work
end;


// CLIENT SIDE

const
_SERVERIP = 'localhost';
_SERVERPORT = 7277;


procedure TForm1.ButtonCoClick(Sender: TObject);
begin
  if not FCLient.Connect then
  begin
    log.d('Can''t connect !!!');
    exit;
  end;
  if FClient.ServerTimeStamp = 0 then
  begin
    log.d('Server incorrect !!!');
    exit;
  end;

  if not FCLient.SetUser(TSQLRestServerAuthenticationDefault, 'TEST', '') then
  begin
    log.d('Can''t login !!!');
    exit;
  end;
  showmessage('CONNECTED !');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FModel := TSQLModel.Create([]);
  FClient := TSQLRestClientHTTP.Create(_SERVERIP, _SERVERPORT, FModel);
end;

Last edited by ep (2017-02-08 17:15:50)

Offline

#2 2017-02-16 09:37:37

ep
Member
Registered: 2017-02-08
Posts: 4

Re: Android rest client authentification

up

Offline

#3 2017-11-24 13:13:37

keinn
Member
Registered: 2014-10-20
Posts: 105

Re: Android rest client authentification

today is all about mobile` , synopse really need a full functional Fmx Client . like login auth, encript, zip/unzip soa restcall etc

Offline

#4 2017-11-24 14:03:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,718
Website

Re: Android rest client authentification

Login and Authentication is implemented, Encryption is done over HTTPS, and SOA REST calls are supported.

Offline

#5 2024-08-19 12:47:17

mormoter
Member
Registered: 2024-06-14
Posts: 20

Re: Android rest client authentification

hello,have you solved it ?

ep wrote:

up

Offline

Board footer

Powered by FluxBB