IMAP auth in Office 365 using OAuth2

19,925

Solution 1

We don't support OAuth for IMAP access to Office 365 and we have no plans to do so as we recommend using our REST APIs to connect to Office 365 for your apps. OAuth is supported for Office 365 REST APIs for mail, calendar and contacts and our older SOAP APIs Exchange Web Services.

Solution 2

We are actively working on OAuth support for IMAP connections to O365 mailboxes. We will make a public announcement once the same is available.

Solution 3

With the new rollout for OAuth 2.0 support for IMAP, I am able to generate the token using the scope

https://outlook.office365.com/IMAP.AccessAsUser.All

But I am still getting

A1 NO AUTHENTICATE failed

I am using the following properties:

props.put("mail.imap.ssl.enable", "true"); 
props.put("mail.imap.auth.mechanisms","XOAUTH2");
props.put("mail.imap.auth.plain.disable", "true");

EDIT: It is working now !

Share:
19,925
Yuri B
Author by

Yuri B

.NET software developer

Updated on July 26, 2022

Comments

  • Yuri B
    Yuri B over 1 year

    I'm using an IMAP client in my program. I'm trying to access to Office 365 outlook by IMAP client using OAuth2 mechanism (using these instructions.)

    When I authenticate in IMAP client - authentication failes, but OAuth2 authentication of Google and Outlook.com works fine. Does Office 365 support OAuth2 authentication in IMAP? If it does, how to authenticate?