Implement REST backend
Brought to you by:
mguessan
Recently the configuration on our Exchange server has changed such that we can still access it via the web using OWA, but not using EWS. Does Davmail have the ability to just talk OWA to get the mail services to work? Are the building blocks there to support such a thing?
Or perhaps an OWA to EWS gateway? Have you seen such a thing?
Unfortunately no, the old Exchange 2003 server had the same endpoint for Webdav/OWA, but now you need EWS endpoint to access all messages/folders.
Note that most Microsoft clients, including Skype for business and Outlook, need EWS access for some features to work properly.
I have since discovered that OWA uses a JSON API, so one could implement this. It may even be possible to convert between the JSON API for OWA and the SOAP API EWS.
https://msdn.microsoft.com/en-us/library/office/dn776319(v=exchg.150).aspx
Unfortunately this new JSON/REST api does not render full MIME message content, will not work.
There's an example of converting this JSON/REST data to EWS and it seems to be rendering full MIME message content.
https://github.com/virtuald/ews-proxy
Very interesting indeed, it looks like they found a way to translate EWS to Json and back almost automatically... And they even reference DavMail as a use case.
=> need to find a way to authenticate against OWA
=> next step would be to have a specific EWSMethod to handle the Json case
For authentication they have a command line program that does it by redirecting the user to the OWA web page and then the tool captures the appropriate authentication bits.
https://github.com/virtuald/ews-proxy/blob/master/cmd/ews-proxy/main.go#L43
It may be possible for DavMail to pretend to be a web browser and fill in the form.
It's a bit more complex than just filling a form, yet the good news is that I have my first PoC to go through authentication on login.microsoftonline.com and send a REST on OWA REST endpoint https://outlook.office365.com/owa/service.svc
Haven't yet tested MFA enabled users though: authentication logic is more complex, with BeginAuth/EndAuth/ProcessAuth
Update: we now have a working implementation of Oauth2 MFA authentication with Office 365, see: https://sourceforge.net/p/davmail/feature-requests/111/
Note that this not enough for on premise Exchange without an available EWS endpoint.
Ticket moved from /p/davmail/support-requests/309/
Most use cases are currently covered to EWS, may need to work on REST in the future