final URLName unusedUrlName = null;
IMAPSSLStore store = new IMAPSSLStore(session, unusedUrlName);
final String emptyPassword = "";
store.connect(host, port, userEmail, emptyPassword);
The important thing here is that we are using an empty password ("") because - well - in XOAUTH2 a password does not make too much sense.
This worked nice with Javamail 1.4.5, but breaks in 1.4.6:
javax.mail.AuthenticationFailedException: Empty username or password. u3if6098339eeo.63
So I am wondering what the best approach. Are we supposed to use the experimental GMailStore? Or is there another way to tell Javamail 1.4.6 that empty passwords are "okay" for now.
I've staged a new version of JavaMail 1.4.7-rc1 that fixes this problem.
You can find it here:
Please try it out and let me know if it indeed does fix the problem for you.