According Microsoft email announce:
Beginning October 13, 2020, we will retire Basic Authentication for EWS, EAS, IMAP, POP and RPS to access Exchange Online. Note: this change does not impact SMTP AUTH.
So it will apply to IMAP also.
But thanks for info and samples for OAuth.