Lars Fosdal 1365 Posted January 12 I am stumped. I can't convince the Delphi TRESTClient to connect to a system using OAuth2 authentication. Either it is a about a parameterization mistake, or it is a functional failure. I can't get it to work with the REST debugger either. Any examples (Other than the RESTdemo) would be appreciated! I have C# code that uses the same creds, and it has no issues. I get access to the system using the Authentication URL with the clientid + clientsecret I request a token through a different URL I call the API URL, using the token Share this post Link to post
Attila Kovacs 518 Posted January 12 (edited) The authentication can be implemented in severeal ways. I would sniff the traffic and see the difference oooooor read the manual. Usually there are some "postman" (Application) examples. Edited January 12 by Attila Kovacs Share this post Link to post
Lars Fosdal 1365 Posted January 12 I have instrumented the C# app with logging, so I see exactly what happens. The challenge is convincing the Delphi REST components to do the same thing. Share this post Link to post
Uwe Raabe 1466 Posted January 12 It is possible that you have to implement it yourself in the way it is needed as it is noted in the docs: Quote TOAuth2Authenticator implements a basic OAuth2 authentication. TOAuth2Authenticator offers minimal support and provides the infrastructure to follow the workflow of the service provider. Inherit from this class to create an authenticator class specific to a service provider. That said, giving a concrete example is difficult without knowing more details. 1 Share this post Link to post
Attila Kovacs 518 Posted January 12 OAuth2 is the authentication protocol. How the credentials are exchanged is up to the service provider. There are some common ways like pass it in the URL (RESTDebugger) or pass it in the headers, pass it in a JSON Object etc... The service provider will give you the documentation and examples. Share this post Link to post
Lars Fosdal 1365 Posted January 12 I think I was fooled by my own expectations with regards to the simplicity of OAuth2 and functional level of the TOAuth2Authenticator. The C# code example can be found here, but it uses another assembly from Thinktecture to do the http parts. https://github.com/LarsFosdal/csharp-ion-api-sdk/blob/master/DotNetBackendOAuth2/Program.cs I'll ponder a little, google some more, and see if I can't crack this nut. Share this post Link to post
Lars Fosdal 1365 Posted January 20 I ended up writing a small class around THTTPClient from System.Net.HttpClient. No need for the humongous REST.* classes. 1 Share this post Link to post