We have a daemon application that makes IMAP connection to access mailbox of user. Earlier we were using plain authentication method of using email ID and password to establish IMAP connection. Now as Microsoft has blocked this type authentication process and introduced oAuth2.0.
My question here I was able to establish IMAP connection with the user that falls inside my tenant. But I am unable to figure out that how it can be done if I need to access the mailbox of user that doesn't fall inside my tenant or need to access the mailbox of any personal outlook account.
I tried to reproduce the same in my environment and got the below results:
Note that, if you want to access the mailbox of user that doesn't fall inside your tenant or need to access the mailbox of any personal outlook account then you have to register a
Multi-Tenant Azure AD Application
like below:I created an Azure AD Multi-Tenant Application and granted the API Permissions:
Now, I registered service principals in Exchange by using below commands:**
I granted service principal access to one mailbox :
I generated the access token via Postman for Multi-Tenant Application by using the parameters like below:
To do the same in
JAVA
, you can refer the below sample code by user3206771 in this SO Thread :