Adding an authentication token to XData default (Aurelius) endpoint calls

Based on the ideas in the excellent book "Hands-on with Delphi", I have added an authentication middleware to my own XData REST server. This middleware receives a username and password and returns a token that can be used for future calls to the server.
The server also uses Aurelius ORM framework, and clients of the XData REST server can access aurelius entities and methods through the default aurelius endpoints.
Testing my authentication middleware from the browser where I pass the token in the URL works just as expected.
I also have a Delphi VCL application which uses TXDataClient to interact with the XData server. A typical request might be FClient.List<TCustomer> which returns a list of TCustomer entities. Now I can only access the list if I append a token to my uri (this is in the format "?T='xxxxx" where xxxxx is the token. How can I add ?T='xxxxx' to FClient.List<TCustomer> so that the XData server will respond to my request as an authenticated user?

Haha - I solved this 5 minutes after posting.

For the benefit of anyone reading this post, it's possible to add the handler in the query string (overloaded method of Client.List) . e.g.
FClient.List<TCustomer>(?T=xxxxx);
Works perfectly :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.