Sorry to resurrect an old thread. Was recently struggling with migrating (using imapsync) an Office365 account, and it seems to do with Microsoft deprecating Basic Auth method for authentication so there's a whole set of hoops to run through to publish an application in Microsft Azure and get an OAuth access token and what-not to use in the imapsync. It's an over-complicated process.
The workaround I chose since it was thankfully only one mailbox was to setup my local Apple Mail.app with the Exchange account, and waited for everything to download locally. I then used it to export the the mailbox folders which it only does in mbox format. This is where our use-cases align I believe as I was wondering how to import this since Cloudron's mail server uses maildir instead of mbox.
I then learned that Roundcube imports mbox data directly, so simply imported through the app interface and it worked well. Just thought I'd add this as an alternative solution for anyone who comes across this in the future. Turns out Microsoft made the whole imapsync process nearly impossible to use due to their deprecation of Basic Auth just recently in October 2022.