I have finally gotten this to work.
Interestingly I had to use the scope https://outlook.office365.com/IMAP.AccessAsUser.All
although by now you have to register your app under the Graph API section in the Azure AD and the proposed Scope is https://graph.microsoft.com/IMAP.AccessAsUser.All
which did not work for me (Authentication failed).
Though I am not sure if that will change in the near future.
I used the properties as stated here: https://javaee.github.io/javamail/OAuth2
props.put("mail.imap.sasl.enable", "true");
props.put("mail.imap.sasl.mechanisms", "XOAUTH2");
props.put("mail.imap.auth.login.disable", "true");
props.put("mail.imap.auth.plain.disable", "true");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…