How to Fix A1 NO AUTHENTICATE Failed for IMAP OAuth 2.0 in Exchange
Question details
The user needs to resolve an authentication failure when using OAuth 2.0 to connect to an IMAP mailbox via a Node.js application.

- Product
- Exchange Online IMAP
- Device & OS
- not provided
- Scenario
- Attempting to authenticate an IMAP connection using an Azure AD-generated OAuth token via the XOAUTH2 mechanism.
- Observed behavior
- The IMAP server rejects the authentication attempt with an "A1 NO AUTHENTICATE failed" error, despite the token successfully working for Microsoft Graph.
Verify that modern authentication (OAuth 2.0) is enabled for your Microsoft 365 tenant and that IMAP access is explicitly turned on for the target mailbox.
Request Correct Exchange Online Scopes and Permissions
Ensure the application requests the correct scopes for Exchange Online instead of Microsoft Graph, as IMAP requires specific Exchange permissions.
A common cause for the NO AUTHENTICATE error is using an access token issued for Microsoft Graph instead of Exchange Online. IMAP authentication strictly requires an Exchange Online token.
For delegated authentication, you must request the specific Outlook IMAP permission and use the default scope.
Navigate to your application in the Azure Portal. Go to API permissions > Add a permission > APIs my organization uses. Search for 'Office 365 Exchange Online' and select it.
Select Delegated permissions and check 'IMAP.AccessAsUser.All'. Click Add permissions, and ensure you grant admin consent for the tenant.
When requesting the token using MSAL in your code, ensure the scope array uses 'https://outlook.office365.com/.default' rather than a Microsoft Graph scope.

Format the XOAUTH2 String Correctly
Construct and base64-encode the XOAUTH2 authentication string according to the strict IMAP protocol specifications.
Configure Service Principals for App-Only Authentication
If you are using the Client Credentials flow (app-only, without a user), you must register an Exchange Online service principal.
Manage Your Documents and Tasks Easily with WPS Office
While troubleshooting complex Exchange server and OAuth configurations often requires extensive development or admin effort, managing your daily productivity shouldn't be difficult. WPS Office provides a lightweight, highly compatible, and user-friendly alternative to Microsoft Office for all your document needs.
- 1. Download WPS Office: Visit the official WPS website to download the free installation package for your operating system.
- 2. Install the application: Run the downloaded installer and follow the simple on-screen instructions to complete the setup.
- 3. Open your files: Launch WPS Office and immediately open, edit, or save your Microsoft Office documents without format loss.

Frequently Asked Questions
Why does my OAuth token work for Microsoft Graph but fail for IMAP?
Tokens generated for Microsoft Graph do not have the proper audience and claims for IMAP authentication. IMAP via Exchange Online requires a token specifically issued for the Exchange Online endpoint, utilizing scopes like 'https://outlook.office365.com/.default'.
How do I check if IMAP is enabled for a Microsoft 365 mailbox?
Log into the Microsoft 365 admin center, navigate to Active users, select the user in question, go to the Mail tab, and click 'Manage email apps'. Ensure that the IMAP checkbox is selected and save the changes.
Does IMAP support the Client Credentials flow (App-Only auth)?
Yes, but it requires additional configuration. You cannot just use Azure AD API permissions. You must register an Exchange Online Service Principal via PowerShell and explicitly grant it 'FullAccess' permissions to the targeted mailboxes.
What is the exact format required for the XOAUTH2 string?
The string must combine the user email and the bearer token using specific ASCII control characters. The unencoded format must be: 'user=mailbox@example.com\x01auth=Bearer YOUR_TOKEN\x01\x01'. It must then be base64-encoded before being sent.




