I am developing an internal application designed to read mailboxes from various Office365 and Outlook accounts using IMAP. The primary goal of this application is to monitor where test emails are delivered, specifically checking if they land in the Inbox or Junk folder.
Currently, I can successfully access the mailboxes of accounts under my tenant. However, I’m facing issues accessing mailboxes of Outlook and other tenant accounts, despite having invited them as Member Users in my Entra ID (a.k.a Azure AD).
While I obtain access and refresh tokens for these accounts just as I do for my tenant accounts, these tokens fail to grant me access to their mailboxes. Instead, I always get a “Request Time Out” error while using them.
Please guide how can I access the mailboxes of such accounts?
P.S:
I’m using @azure/msal-node package and utilizing ConfidentialClientApplication for OAuthentication.
I’ve chosen Supported Account types to “Accounts in any organizational directory and personal Microsoft accounts” in App Registration page.
Following are the scopes I’m using in the request:
"offline_access",
"https://outlook.office.com/IMAP.AccessAsUser.All",
"openid",