Does test outlook email supports OAuth Token Based Authentication to read email message's.

test16 1028 0 Reputation points
2023-08-01T04:52:01.0233333+00:00

am having a test outlook email which doesn't have any active subscription for Azure Active Directory.

I have registered my application. in Azure Active Directory and started reding the test email message in java code base using javax.mail library.

but what happening always am getting Authentication Failed exception does it needs the active subscription.

Code base am using.

Properties props = new Properties();
		props.put("mail.imaps.sasl.enable", "true");
		props.put("mail.imaps.sasl.mechanisms", "XOAUTH2");
		props.put("mail.imaps.sasl.mechanisms.oauth2.oauthToken", "accessToken");
		Session session = Session.getInstance(props);

		IMAPStore store = new IMAPStore(session, null);

try { 			
		store.connect("outlook.office365.com", 993, "AccessToken", ""); 			   				          	
} catch (MessagingException e) { 
			throw e; 		
}
A1 NO AUTHENTICATE failed.
Exception in thread "main" 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.oauth.sample.ConnectOutEmailByPassingAccessToken.main(ConnectOutEmailByPassingAccessToken.java:52)
Outlook
Outlook
A family of Microsoft email and calendar products.
3,427 questions
Outlook Management
Outlook Management
Outlook: A family of Microsoft email and calendar products.Management: The act or process of organizing, handling, directing or controlling something.
5,072 questions
0 comments No comments
{count} votes