IMAP OAuth2 MAILKIT Microsoft Authentication Failed

Credoffice Support 5 Reputation points
2025-02-05T09:59:27.9066667+00:00

I'm already working on mailboxes received from Microsoft with Mailkit IMAP and I've done the configuration with OAuth2 required from the office account!

my problem is that I receive the token but during the authentication I get an "Authentication failed" exception!

I assume this is because Microsoft's IMAP and OAuth2 configurations need to be enabled in Azure, I've tried enabling them but it still doesn't work .. !!

Microsoft 365
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
5,711 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,024 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
3,021 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. BANDELA Siri Chandana 1,485 Reputation points Microsoft Vendor
    2025-02-06T05:02:35.1266667+00:00

    Hi @Credoffice Support
    Thank you for posting your issue on Microsoft Q&A.

    I understand that you are working on mailboxes received from Microsoft with Mailkit IMAP and you have done the configuration with OAuth2 but during the authentication you get an "Authentication failed" exception.

    Screenshot 2025-02-06 102842 There is no plan for Outlook clients to support OAuth for POP and IMAP, but Outlook can connect use MAPI/HTTP (Windows clients) and EWS (Outlook for Mac).

    If you're using POP/IMAP and SMTP for an Exchange Online account in Outlook, you must enable Basic authentication for these protocols (until it's permanently deprecated in October 1). To do so, disable Microsoft Entra security defaults if they're enabled.

    Follow the document for more information: https://learn.microsoft.com/en-us/exchange/troubleshoot/administration/cannot-connect-mailbox-pop-imap-outlook?source=recommendations

    Hope this helps. Do let us know if you have any further queries.

    If this answers your query, do click `Accept Answer` and `Yes`.

    Thanks,

    B. Siri Chandana.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.