How email using OAuth and Exchange Online

Philip Tulett philip.tulett at pdq-networks.com
Tue Jul 12 08:36:03 UTC 2022


Hi Michael,

I have multiple apps that are connecting to Exchange / O365 to send and retrieving messages using ow3 objects.

>From what you have said, you are just sending emails, at this time MS are continuing to support Basic Auth for SMTP Sending:-
https://techcommunity.microsoft.com/t5/exchange-team-blog/improving-security-together/ba-p/805892
That said, if you are going to refactor the code to use the new worker object, it would be worth going to OAUTH at the same time.
https://techcommunity.microsoft.com/t5/exchange-team-blog/basic-authentication-and-exchange-online-april-2020-update/ba-p/1275508
https://docs.microsoft.com/en-gb/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth

Pointers:-
Generally, MS tokens have a life of about an hour, so expect to receive an updated token at that rate, that will need to be saved for next connection, so capture the call to $tokensrefreshed and then save the OAUTH buffer using Do iOAUTH2.$save(iSavedOAUTHBuffer,iKey) Returns lOK
I encrypt the OAUTH buffer with a key, then save it to a binary field in the database so can be used at the next call or if the apps stops and restarts.
So, when starting a connection, I load the latest OAUTH buffer from the database.
To reduce user interaction/reauthorisation, when setting up the in AZURE, include the following tin the Scope API:- 
	offline_access
	https://outlook.office.com/SMTP.Send
I my case I also include
	https://outlook.office.com/POP.AccessAsUser.All
	https://outlook.office.com/IMAP.AccessAsUser.All
The above will need to be include in your initial Authorization request 
If you have multiple servers that could perform the token refresh, make sure that you include them in all the Redirect URI's in AZURE.
If you will be using the Omnis Runtime's I recommend setting a unique static port for each of them (see above on Redirect URI's) in their server options "RESTful connections"
 
HTH


Kind regards
Philip Tulett

-----Original Message-----
From: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> On Behalf Of Michael Houlberg
Sent: 11 July 2022 19:07
To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
Subject: Re: How email using OAuth and Exchange Online

Mike,

Thanks, I’m sure I’ll be talking with you in the future.  I see that right now I should probably make the move from SMTPSend to oSMTPWorker as a first step, since I already know how to do that.

Thanks,
Michael Houlberg
Houlberg Development, LLC

> On Jul 11, 2022, at 11:04 AM, Mike Matthews - Omnis via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
> 
> I’m in the middle of using oAuth2 for Exchange / O365 / Azure.
> 
> Most done, just need to tidy up.
> 
> Mike Matthews
> 
> Lineal Software Solutions
> Commercial House, The Strand<x-apple-data-detectors://1/1> Barnstaple, 
> Devon, EX31 1EU<x-apple-data-detectors://1/1>
> 
> omnis at lineal.co.uk<mailto:mike.matthews at lineal.co.uk>
> 
> www.lineal.co.uk<http://www.lineal.co.uk/>
> 
> www.sqlworks.co.uk<http://www.sqlworks.co/>
> 
> 
> 
> On 11 Jul 2022, at 18:55, Michael Houlberg <michael at houlbergdevelopment.com<mailto:michael at houlbergdevelopment.com>> wrote:
> 
> $Listers:
> 
> My client who is part of a University, tells me that this fall they are dropping support for the type of email we have been using in favor of Exchange Online and using OAuth to authenticate.  Currently we send lots of emails using SMTPSend.  For another client I have had experience using the oSMTPWorker object.  But I haven’t had to deal with either oAuth or Exchange Online Server.
> 
> Does anyone have some pointers on this they can share?
> 
> Thanks,
> Michael Houlberg
> Houlberg Development, LLC
> _____________________________________________________________
> Manage your list subscriptions at 
> https://linkprotect.cudasvc.com/url?a=https%3a%2f%2flists.omnis-dev.co
> m&c=E,1,VF9Rn-JHUso614RklDy6ab1e38c_b_Z94_OemBOgjTfQUsWcqLrhXVC5OPx1Jj
> vQeQxk7_FQ1m6o4ThS5_KBhUfHFAjz1rm7xGQxq148o4eXWT3dGAcOwRlM&typo=1
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com Start a 
> new message -> mailto:omnisdev-en at lists.omnis-dev.com

_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 



More information about the omnisdev-en mailing list