It turns out that the commons net IMAP package can do oauth2 style of authentication just fine.  I can do this:

String userNamePlusAccessToken = combine( username, accessToken )

according to e.g.

https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth

or

https://developers.google.com/gmail/imap/xoauth2-protocol

I got the OAuth2 accessToken via use of msal4j:

https://github.com/AzureAD/microsoft-authentication-library-for-java

Then

AuthenticatingIMAPClient aic = new AuthenticatingIMAPClient(true);

  aic.connect( server );

   aic.auth( AuthenticatingIMAPClient.AUTH_METHOD.XOAUTH2,
                   userNamePlusAccessToken, "passwordNotUsed" );

Just wanted this documented should others need to solve same problem.

Stuart



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to