mguessan / davmail

DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange and Office 365 Gateway - Synced with main subversion repository at
http://davmail.sourceforge.net
GNU General Public License v2.0
580 stars 86 forks source link

DavMail with O365 modern authentication doesn´t work #285

Open trnxtrnx opened 1 year ago

trnxtrnx commented 1 year ago

Hello. I have a problem to setup DavMail (in server mode) with O365 modern authentication and I can´t find any useful information. In my scenario, there is not possible to use GUI application with O365Interactive mode (because of stupid company rules..). Our accounts have a MFA forced.

I followed information which is presented here: https://davmail.sourceforge.net/faq.html and I updated my davmail.properties: davmail.oauth.clientId=Real-App-ID davmail.oauth.tenantId=Real-Tenant-ID davmail.oauth.redirectUri=https://login.microsoftonline.com/common/oauth2/nativeclient davmail.url=https://outlook.office365.com/EWS/Exchange.asmx

First, when I kept "davmail.mode" with EWS and I tried to connect to mailbox via Thunderbird I get error: "Authentication failed: invalid user or password". I understand this error, probably because MFA is enabled. So I changed mode to O365Modern and when I tried to connect to mailbox, I get error: "All network interfaces down or host unreachable !" After that, I changed mode to O365Manual (with trunk files), but I get another error which I didn´t write (I think it was something with Java FX, but I am not sure)..

I know the O365Interactive mode works good, but I am not able to use it in company environment.

Maybe I did something wrong when I registered app in tenant (but I did it three times). Can somebody help me? Post some steps how to properly register app in tenant (if there is some special permissions or something like that)?

Thank you very much for any help.

mguessan commented 1 year ago

Usually you don't need the tenantid set.

Did you try with default DavMail clientId ? It should already have the scopes required for DavMail to work. As Microsoft started deprecating some Exchange related APIs I wouldn't be surprised if a newly created clientId does not work.

Anyway another workaround is to use Outlook desktop clientId: davmail.oauth.clientId=d3590ed6-52b3-4102-aeff-aad2292ab01c davmail.oauth.redirectUri=urn:ietf:wg:oauth:2.0:oob

O365Modern does not cover all authentication use cases, e.g. number matching enforced since early may on most tenants is not supported. Thus your best bet at the moment is O365Manual.

O365Manual should not depend on JavaFX, but use a recent JDK anyway, on Windows use the standalone package that comes with embedded JRE.

Then grab authentication link from popup, proceed with authentication and paste back returned code. For DavMail clientId the code will be available in url of the blank page. For Outlook desktop you will have to check dev tools for last request that will contain the last redirect with the urn: link, paste this back in DavMail