I'm absolutely sure that the article you mention:
https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp
...is up-to-date and contains all steps required to authenticate.
Please follow it carefully, double check every guid you enter.
Note that, every step is required - this includes assigning permissions using PowerShell.
1.
Start with troubleshooting with these PowerShell commands:
Get-ServicePrincipal
Get-MailboxPermission -Identity "AdeleV@your-domain.onmicrosoft.com"
ServiceId and User should match.
Then make sure the ServiceId is the same as the Object ID on the Enterprise Application screen (do not use the value from the App Registration screen - this is the most common mistake people tend to make)
Make sure the AppId is the same as the Application ID on the Enterprise Application screen
2.
Check if you can connect to this account using IMAP and regular interactive flow:
https://www.limilabs.com/blog/office-365-oauth-2-0-imap-pop3-email-client-connectivity-tools
This proves you have IMAP access properly configured.
If it doesn't work make sure IMAP/POP3 is enabled for your organization and mailbox:
https://www.limilabs.com/blog/office365-enable-imap-pop3-smtp
3.
Check if you added correct permissions and have granted Admin consent for your domain.
4.
Usually people use incorrect client/tenant ids/secrets – double check every single value you enter (also for additional spaces).
5.
You may need to wait up to 30 minutes for some changes to take effect.