-
Content Count
102 -
Joined
-
Last visited
-
Days Won
2
Everything posted by mjustin
-
Delphi - send mail from Office 365 with EWS protocol
mjustin replied to J23's topic in ICS - Internet Component Suite
Meanwhile I managed to send email using MS Graph API. The example project with full source code is described here: Microsoft identity platform and OAuth 2.0 authorization code flow example for Daraja HTTP Framework The Authorization Code Flow with Proof Key for Code Exchange (PKCE) is a recommended OAuth 2.0 flow for native apps. No client secret is required in this flow. Instead, a secret is created by the calling application that can be verified by the authorization server. The example application requests an authorization code, redeems the code for an access token, and then calls the Microsoft Graph API to retrieve user profile data, and to send an email on behalf of the signed-in user. It may be a starting point for a ICS based application. -
Send mails via the Graph API: a new example project for the Daraja HTTP Framework demonstrates how to get an access token using the implicit grant flow, and how to invoke the Graph API to send an email. No additional configuration is required, as the project uses an existing Microsoft Entra App registration , which is limited to the permissions for reading the user profile and sending emails. You may configure your own App registration and use its Application (client) ID in the source code of unit MainUnit, or contact me to provide a modified App registration.
-
Update / new blog post: Microsoft identity platform and OAuth 2.0 authorization code flow example for Daraja HTTP Framework The Authorization Code Flow with Proof Key for Code Exchange (PKCE) is a recommended OAuth 2.0 flow for native apps. No client secret is required in this flow. Instead, a secret is created by the calling application that can be verified by the authorization server. The example application requests an authorization code, redeems the code for an access token, and then calls the Microsoft Graph API to retrieve user profile data, and to send an email on behalf of the signed-in user. Software requirements * Daraja HTTP Framework (https://github.com/michaelJustin/daraja-framework). The example code is located in the entra_auth_code_flow folder of the master branch. * Indy (https://github.com/IndySockets) with OpenSSL DLLs for Indy (https://github.com/IndySockets/OpenSSL-Binaries) * JsonDataObjects (https://github.com/ahausladen/JsonDataObjects) Daraja HTTP Framework download: - https://github.com/michaelJustin/daraja-framework
-
Using ChatGPT I got some helpful basic steps: Q: How can a Delphi application use the Outlook.Application ActiveX to read a user calendar? A: To use the Outlook.Application ActiveX in a Delphi application to read a user's calendar, you can follow these general steps. Please note that you need to have Outlook installed on the machine where your Delphi application is running. (Steps and source code omitted) Q: Is it also possible to read the calendar of a different user? A: Accessing the calendar of a different user using the Outlook.Application ActiveX in Delphi depends on the permissions and configuration of the Outlook profile. Generally, the ability to access another user's calendar requires the appropriate permissions and security settings. (Again, steps and code omitted here, except the following two lines: // Replace 'otheruser@example.com' with the email address of the user whose calendar you want to access OtherUserCalendar := Namespace.GetSharedDefaultFolder('otheruser@example.com', olFolderCalendar); I do not post more as I am not sure if AI-generated answers are acceptable in this forum ---- Note: using the MS Graph API (or EWS) may be also an option, with the advantage that no local Outlook is required.
-
Habarisoft released new versions of the native STOMP client libraries for Delphi / Object Pascal for integration with popular open source message brokers: Habari STOMP Client for ActiveMQ 8.4 – tested with Apache ActiveMQ 5.18.3 Habari STOMP Client for Artemis 8.4 – tested with Apache ActiveMQ Artemis 2.31.0 Habari STOMP Client for OpenMQ 8.4 – tested with Eclipse OpenMQ 6.4.0 Habari STOMP Client for RabbitMQ 8.4 – tested with RabbitMQ 3.12.7 and 3.13.0-rc.1 Release notes: https://www.habarisoft.com/release_notes.html
-
Habari STOMP Client libraries release 2023.10
mjustin replied to mjustin's topic in Delphi Third-Party
Habarisoft released new versions of the native STOMP client libraries for Delphi / Object Pascal for integration with popular open source message brokers: Habari STOMP Client for ActiveMQ 8.5 – tested with Apache ActiveMQ 5.18.3 and 6.0.0 Habari STOMP Client for Artemis 8.5 – tested with Apache ActiveMQ Artemis 2.31.2 Habari STOMP Client for OpenMQ 8.5 – tested with Eclipse OpenMQ 6.4.0 Habari STOMP Client for RabbitMQ 8.5 – tested with RabbitMQ 3.12.10 and 3.13.0-rc.2 Release notes: https://www.habarisoft.com/release_notes.html -
Got message 'HTTP/1.1 401 Unauthorized' when tried to access user profile (https://graph.microsoft.com/v1.0/me)
mjustin replied to Officeapi's topic in Network, Cloud and Web
Could you attach/upload the last version of your code? This would make it easier to reproduce the issue and to create a bug report for it. -
Got message 'HTTP/1.1 401 Unauthorized' when tried to access user profile (https://graph.microsoft.com/v1.0/me)
mjustin replied to Officeapi's topic in Network, Cloud and Web
The Content-Type header value looks suspicious: application%2Fjson RESTListResGroupResponse.JSONValue maybe is empty because the content type is not the expected one, application/json As can be seen in the screen shot, all other slashes are not encoded as #2F. If the request header Content-Type is not required, just remove it from the request setup and try if this helps. -
Got message 'HTTP/1.1 401 Unauthorized' when tried to access user profile (https://graph.microsoft.com/v1.0/me)
mjustin replied to Officeapi's topic in Network, Cloud and Web
Sorry for my mistake, I mistook a post of a different user as being from you. If the postman call succeeds, I'd check every single HTTP element and modify the Delphi request to be the same. Postman shows all headers and payloads. One header, which is frequently said to be causing errors, is the User-Agent. So I'd check and use the same header that Postman uses. -
Got message 'HTTP/1.1 401 Unauthorized' when tried to access user profile (https://graph.microsoft.com/v1.0/me)
mjustin replied to Officeapi's topic in Network, Cloud and Web
Did you check https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http#permissions? A potential reasons for the 401 is the missing scope User.ReadAll. You wrote that you use Application type. For the Application permission type, the table says that the "Least privileged permission" is User.Read.All, however, yor code uses User.Read: RESTTokenRequest.Params.AddItem('scope', 'openid profile offline_access Mail.Read Mail.Send User.Read', TRestRequestParameterKind.pkREQUESTBODY); Also, for testing user profile access, there is no need to include the scopes profile, offline_access, Mail.Read and Mail.Send. Try this: RESTTokenRequest.Params.AddItem('scope', 'openid User.ReadAll', TRestRequestParameterKind.pkREQUESTBODY); The API documentation also explains that with Application permission type, only the admin can consent. Calling the API endpoint https://graph.microsoft.com/v1.0/me may return the admin user profile only. If you need the user profile of other users, use the HTTP request described in https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http#http-request /users/{id | userPrincipalName} Hope this helps -
Datasnap Server doesn't response after awhile?
mjustin replied to Mustafa Simsek's topic in Network, Cloud and Web
Does the server run out of resources? What does netstat say about client connections? Does the server cleanup (remove) stale connections? -
With Indy, the recommended way to send a message to a specific client is to assign an unique client id to new connections in the OnConnect method of the server. The server application then can use the client id to limit the message to one (or some) of the connected clients. Technically, the client id would be a property in a subclass of the TIdContext class, and this class must be "registered" with the Indy TCP server. There are plenty of articles on the web covering this technique.
-
Habari STOMP Client libraries 2023.02 released, now supporting mORMot TCP client
mjustin posted a topic in Delphi Third-Party
The 2023.02 release adds new adapters for mORMot 1 and 2, in addition to the Internet Direct (Indy) and Synapse (r266) adapters. This release contains: Habari STOMP Client for ActiveMQ 8.0 - tested with Apache ActiveMQ 5.17.3 - https://activemq.apache.org/ Habari STOMP Client for Artemis 8.0 - tested with Apache ActiveMQ Artemis 2.28.0 - https://activemq.apache.org/components/artemis/ Habari STOMP Client for OpenMQ 8.0 - tested with Eclipse OpenMQ 6.3.0 and 6.4.0-SNAPSHOT - https://github.com/eclipse-ee4j/openmq Habari STOMP Client for RabbitMQ 8.0 - tested with RabbitMQ 3.10.17 and 3.11.8 - https://www.rabbitmq.com/ Release 8.0 brings minor breaking changes, please check the included "Getting Started" documentation (PDF). Release notes: Full release notes can be found at: https://www.habarisoft.com/release_notes.html Home page, demo download, full documentation: https://www.habarisoft.com/ -
Habari STOMP Client libraries 2023.02 released, now supporting mORMot TCP client
mjustin replied to mjustin's topic in Delphi Third-Party
Habari STOMP Client libraries release 2023.08 Habarisoft released new versions of its native STOMP client libraries for Delphi / Object Pascal for integration with popular open source message brokers: Habari STOMP Client for ActiveMQ 8.3 – tested with Apache ActiveMQ 5.18.2 Habari STOMP Client for Artemis 8.3 – tested with Apache ActiveMQ Artemis 2.30.0 Habari STOMP Client for OpenMQ 8.3 – tested with Eclipse OpenMQ 6.4.0 Habari STOMP Client for RabbitMQ 8.3 – tested with RabbitMQ 3.11.20, 3.12.2, 3.13.0-beta.3 Release notes: https://www.habarisoft.com/release_notes.html -
marsRequest.RemoteIP empty when using ISAP, filled when using cmdline (indy)
mjustin replied to mvanrijnen's topic in MARS-Curiosity REST Library
Does marsRequest.RemoteIP contain an empty string, or an unexpected value? And do the other fields of marsRequest contain sensible (non-default) values? -
It is a very simple POST method request to a HTTPS address and with a JSON body. A small example how this can be done with Indy (included in Delphi) is here: https://mikejustin.wordpress.com/2015/03/14/indy-10-6-https-post/ Line 16 defines the body of the message. Replace it with your required JSON string. Line 21 send the message, change the server address to your destination server. It requires the OpenSSL DLLs which can be downloaded from https://github.com/IndySockets/OpenSSL-Binaries
-
ScroogeXHTML for Object Pascal is a library which supports a subset of the Rich Text Format (RTF) standard. It converts RTF to HTML5 and XHTML standalone documents, or to fragments which can be embedded in other documents. ScroogeXHTML is compatible with Delphi 2009+ and Free Pascal 3.2.0. Home page, Getting Started PDF, and demo download: https://www.scroogexhtml.com/object_pascal.html API online: https://www.habarisoft.com/scroogexhtml/8.3/docs/api/
-
ScroogeXHTML 8.3 - RTF to HTML5 and XHTML converter
mjustin replied to mjustin's topic in Delphi Third-Party
ScroogeXHTML for Object Pascal 8.4 released ScroogeXHTML for Object Pascal is a library which supports a subset of the Rich Text Format (RTF) standard. It converts RTF to HTML5 and XHTML stand-alone documents, or to fragments which can be embedded in other documents. The library is compatible with Delphi 2009+ and Free Pascal 3.2.0. The 8.4 release fixes some minor issues. Full release notes are at https://www.habarisoft.com/scroogexhtml/8.4/docs/api/version.html Home page, Getting Started PDF, and demo download: https://www.scroogexhtml.com/object_pascal.html API online: https://www.habarisoft.com/scroogexhtml/8.4/docs/api/ -
Habari STOMP Client libraries 2023.02 released, now supporting mORMot TCP client
mjustin replied to mjustin's topic in Delphi Third-Party
Habari STOMP Client libraries release 2023.06 Habarisoft released new versions of its native STOMP client libraries for Delphi / Object Pascal for integration with popular open source message brokers: Habari STOMP Client for ActiveMQ 8.2 – tested with Apache ActiveMQ 5.18.0 Habari STOMP Client for Artemis 8.2 – tested with Apache ActiveMQ Artemis 2.28.0 Habari STOMP Client for OpenMQ 8.2 – tested with Eclipse OpenMQ 6.4.0 Habari STOMP Client for RabbitMQ 8.2 – tested with RabbitMQ 3.12.0 This version contains a new decoder for STOMP header lines. -
Apache ActiveMQ supports MQTT (and other protocols) and discovery: https://activemq.apache.org/discovery With Delphi: https://mikejustin.wordpress.com/2021/08/14/discover-activemq-brokers-with-delphi-xe4-and-indy-10-6/
-
Can Delphi set session data in opening a webpage?
mjustin replied to PiedSoftware's topic in Network, Cloud and Web
Whether the credentials will be saved (or updated) in the browser app is typically a user choice, presented after the login data is entered. Unless this feature is disabled completely. Can you give more information about environment / use case / functional requirements? -
The Daraja HTTP Server Framework is a free open source library for Object Pascal (Free Pascal 3,1.0 or Delphi 2009+), based on the stand-alone HTTP server component in Internet Direct (Indy). With the 2.5-SNAPSHOT release, most code is now single-source and more readable, there are no "IFDEF FPC" branches anymore to use the Free Pascal fgl generics library. All DUnit / FPCUnit - based tests run successfully. The full 2.5-SNAPSHOT source and demo code is available at GitHub. Demo applications cover - for example - OAuth 2.0 and Twitter Bootstrap. More information - GitHub: https://github.com/michaelJustin/daraja-framework - API documentation: http://michaeljustin.github.io/daraja-framework/ - Wiki: https://github.com/michaelJustin/daraja-framework/wiki - Features and FAQ: https://www.habarisoft.com/daraja_framework.html
-
Daraja HTTP Server Framework 2.5 preview snapshot
mjustin replied to mjustin's topic in Delphi Third-Party
The Daraja HTTP Server Framework is a free open source library for Object Pascal (Free Pascal 3.2.0 or Delphi 2009+), based on the HTTP server component in Internet Direct (Indy). New: the 2.6-SNAPSHOT includes a first implementation of the Web Filter API, which allows pre- and postprocessing of HTTP requests and responses. Web Filters are useful for example to add logging and auditing, input validation, or authentication. Filters may be composed in filter chains, where the order of filter execution is defined by the order of registration. Web Filter instances may configured through init parameters. Example code In the test example below, the Web Component TExamplePage returns the plain-text response "example", and the filters (TTestFilterA and TTestFilterB) add the texts " (A)" and " (B)" to the response. The client therefore receives the response "example (A) (B)". Code: Pascal [Select][+] procedure TAPIConfigTests.TestTwoFilters; var Server: TdjServer; Context: TdjWebAppContext; begin Server := TdjServer.Create; try Context := TdjWebAppContext.Create('web'); // Context located at http://<server:port>/web/ Context.AddWebComponent(TExamplePage, '*.txt'); // Web Component responds to all requests for txt documents Context.AddWebFilter(TTestFilterA, TExamplePage); // Web Filter A will be processed first and appends " (A)" Context.AddWebFilter(TTestFilterB, TExamplePage); // Web Filter B will be processed second and appends " (B)" Server.Add(Context); Server.Start; CheckGETResponseEquals('example (A) (B)', '/web/test.txt'); finally Server.Free; end; end; Code for the DoFilter method of TTestFilterA: procedure TTestFilterA.DoFilter(Context: TdjServerContext; Request: TdjRequest; Response: TdjResponse; const Chain: IWebFilterChain); begin Chain.DoFilter(Context, Request, Response); // invoke other filters and eventually the Web Component Response.ContentText := Response.ContentText + ' (A)'; end; Full source code, including DUnit and FPCUnit tests, is available at GitHub. The Web Filter API specification is still in development and may still see minor and major changes. More information - GitHub: https://github.com/michaelJustin/daraja-framework - 2.6-SNAPSHOT API documentation: https://michaeljustin.github.io/daraja-framework/2.6-SNAPSHOT/ - Project home page: https://www.habarisoft.com/daraja_framework.html -
Habari STOMP Client libraries 2023.02 released, now supporting mORMot TCP client
mjustin replied to mjustin's topic in Delphi Third-Party
Habari STOMP Client libraries release 2023.04 Habarisoft released new versions of its native STOMP client libraries for Delphi / Object Pascal for integration with popular open source message brokers: Habari STOMP Client for ActiveMQ 8.1 – tested with Apache ActiveMQ 5.18.0 Habari STOMP Client for Artemis 8.1 – tested with Apache ActiveMQ Artemis 2.28.0 Habari STOMP Client for OpenMQ 8.1 – tested with Eclipse OpenMQ 6.4.0 Habari STOMP Client for RabbitMQ 8.1 – tested with RabbitMQ 3.11.12 This version is mainly a maintenance release and tested with the latest message broker versions. Full release notes can be found at: https://www.habarisoft.com/release_notes.html Home page: https://www.habarisoft.com/ -
Protected TCP/IP Client/Server connection
mjustin replied to shineworld's topic in Network, Cloud and Web
Yes, this would cause more work / administration. But maybe you missed the last part: "The accepted answer describes a different solution, using a 'user cert store. (...)" With this solution, no additional user would be needed. The certificate will reside in a user cert store, and is readable only for the user, inaccessible for other users.. Currenly the client is in Python: > For the client I use python while the server is done with Indy 10 using TIdTCPServer. So if there is Python support for cert stores it should be solvable. Alternatively, with Delphi, other HTTP clients may support reading from cert stores (TNetHTTPClient or others).