#1 2019-04-24 14:14:28

BrainCell
Member
Registered: 2019-03-14
Posts: 3

Trouble connecting to mORMot data via TSynRestDataset

Following the example in: 
  mORMot\SQLite3\Samples\ThirdPartyDemos\EMartin\TSynRestDataset

I modified the mORMot\SQLite3\Samples\04 - HTTP Client-Server example to contain a TSynRestDataset that should be able to connect to the SampleModel data as such:

  Model := CreateSampleModel; // from SampleData unit
  ds := TSynRestDataset.Create(Self);
  ds.DataSet.SQLModel := Model;
  ds.CommandText := 'http://localhost:8080/root/SampleRecord?select=Time,Name,Question&sort=ID';
  ds.Open;

Upon running the ds.Open; I get :

First chance exception at $7C812FD3. Exception class ESynException with message 'Error
Authentication Failed: Invalid signature (0)
from
http://localhost:8080/root/SampleRecord?select=Time,Name,Question&sort=ID'. Process Project04Client.exe (103652)

What might I be missing? I know the server is running, because the I didn't remove the Project04Client controls, and they still work even after the Exception.

Offline

#2 2019-04-24 15:26:29

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

Re: Trouble connecting to mORMot data via TSynRestDataset

The exception text may help: the signature is invalid.

I guess you are accessing a Server with authentication enabled from a client with no authentication.
The request is therefore rejected.

Offline

#3 2019-04-29 14:27:40

BrainCell
Member
Registered: 2019-03-14
Posts: 3

Re: Trouble connecting to mORMot data via TSynRestDataset

Arnaud,

So the question is, how do I authenticate?

Project04Client.dpr authenticates like this:
  TSQLHttpClient(Form1.Database).SetUser('User','synopse');

I suspect that TSynRestSQLDataSet.OnGetURISignature needs to be implemented, but there's no example in the documentation on how to implement it.
I've seen that "&session_signature=..." is added, but I can't find a method that generates the signature.

Offline

#4 2019-04-29 14:29:44

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

Re: Trouble connecting to mORMot data via TSynRestDataset

IIRC TSynRestDataset does not support authentication.

It is a third-party sample, not maintained by the main source code base.

Offline

Board footer

Powered by FluxBB