I'm trying to connect outlook mail through Java Mail API. My outlook account is Multi Factor Authenticated (MFA)using ping Identity.
I can generate a ping Id token as it mentioned here.
Now my question is how can pass this token from Java mail Api to connect my outlook account ?
Debug Result:
DEBUG: setDebug: JavaMail version 1.6.2
DEBUG: getProvider() returning
javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]
DEBUG IMAP: mail.imap.fetchsize: 16384
DEBUG IMAP: mail.imap.ignorebodystructuresize: false
DEBUG IMAP: mail.imap.statuscachetimeout: 1000
DEBUG IMAP: mail.imap.appendbuffersize: -1
DEBUG IMAP: mail.imap.minidletime: 10
DEBUG IMAP: closeFoldersOnStoreFailure
DEBUG IMAP: trying to connect to host "imap-mail.outlook.com", port 993, isSSL true
* OK The Microsoft Exchange IMAP4 service is ready.
[QwBPADIAUABSADAANgBDAEEAMAAwADUAOAAuAG4AYQBtAHAAcgBkADAANgAuAHAAcgBvAGQALgBvAHUAC4AYwBvAG0A]
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
A0 OK CAPABILITY completed.
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: AUTH: XOAUTH2
DEBUG IMAP: protocolConnect login, host=imap-mail.outlook.com,
[email protected], password=<non-null>
DEBUG IMAP: AUTHENTICATE XOAUTH2 command trace suppressed
DEBUG IMAP: AUTHENTICATE XOAUTH2 command result: A1 NO AUTHENTICATE failed.
javax.mail.AuthenticationFailedException: AUTHENTICATE failed.
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:732)
at javax.mail.Service.connect(Service.java:366)
at javax.mail.Service.connect(Service.java:246)
at com.outlook.outlook.controller.TestController.mailDetails(TestController.java:54)
Instead of auth token use app password for authentication. You can generate app password from Outlook - view account -> security.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With