IMAP OAuth AUTHENTICATE failed error when connecting to Microsoft 365Issue You followed Configure SMTP and IMAP email accounts with Microsoft Office365 using OAuth2 But are still unable to do the test connection. Getting below error. ****** 2021-06-09 08:13:23 Finalizer SYSTEM DEBUG: IMAP: IMAPStore cleanup, not connected2021-06-09 08:13:17 Starting: Email Reader.91616b03c611227b014e3d95b7f9d1dd, Trigger Type: Interval, Priority: 25, Upgrade Safe: true, Repeat: 2 minutes2021-06-09 08:13:17 Name: Email Reader2021-06-09 08:13:17 DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]2021-06-09 08:13:17 DEBUG: IMAP: trying to connect to host "outlook.office365.com", port 993, isSSL true2021-06-09 08:13:18 DEBUG: * OK The Microsoft Exchange IMAP4 service is ready. [ABC]2021-06-09 08:13:18 DEBUG: BEI0 CAPABILITY2021-06-09 08:13:18 DEBUG: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+2021-06-09 08:13:18 DEBUG: BEI0 OK CAPABILITY completed.2021-06-09 08:13:18 DEBUG: IMAP: AUTH: PLAIN2021-06-09 08:13:18 DEBUG: IMAP: AUTH: XOAUTH22021-06-09 08:13:18 DEBUG: IMAP: protocolConnect login, host=outlook.office365.com, user=test@test.com, password=<non-null>2021-06-09 08:13:18 DEBUG: IMAP: SASL authentication command trace suppressed2021-06-09 08:13:18 DEBUG: IMAP: SASL Mechanisms:2021-06-09 08:13:18 DEBUG: IMAP: XOAUTH22021-06-09 08:13:18 DEBUG: IMAP: SASL client XOAUTH22021-06-09 08:13:18 DEBUG: IMAP: SASL callback length: 12021-06-09 08:13:18 DEBUG: IMAP: SASL callback 0: javax.security.auth.callback.NameCallback@986a082021-06-09 08:13:18 AUTHENTICATE failed.2021-06-09 08:13:18 Completed: Email Reader in 0:00:01.135, next occurrence is 09/06/2021 17:14:34 ******* Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Any Cause<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Oauth Scopes were missing below URLs instead have values like SMTP.Send and IMAP.AccessAsUser.All Authenticate an IMAP, POP or SMTP connection using OAuth IMAPhttps://outlook.office.com/IMAP.AccessAsUser.AllSMTP AUTHhttps://outlook.office.com/SMTP.Send Navigate to All > System Oauth > Application Registry > Select M365 record previously created and compare to screenshot: Resolution Add following URLs to the respective scopes in ServiceNow (All > System Oauth > Application Registry > Select M365 record previously created) https://outlook.office.com/IMAP.AccessAsUser.All https://outlook.office.com/SMTP.Send - Create a brand new Email Account (IMAP), this step is required (All > System Mailbox > Administration > Email Accounts ) - Authorize new account and test connection. Related Links<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Check external resources for additional info.