0 votes

I try to make an IMAP connection and login with oAuth2. (Used your blog: https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp).

I granted full access for 2 mailboxes but I get failed Authenticate error despite I have a valid token.

Any tips for me to solve this problem ?

by

1 Answer

0 votes
 
Best answer

You need to perform every single step that is described there:
https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp

Usually people use incorrect ids and/or invalid scope - double check every single value you enter.

Another common mistake is not performing "Grant admin consent" step, it is also important to allow modern authentication, making sure to disable security defaults, and double checking that conditional access policies are not blocking access:

https://www.limilabs.com/blog/office365-enable-imap-pop3-smtp

Double check PowerShell commands as well:

Get-ServicePrincipal
Get-MailboxPermission  -Identity "TODO@domain.onmicrosoft.com"

Have in mind, it takes 20-30 minutes for some changes (e.g. enabling IMAP) to take effect.

by (304k points)
...