[ https://issues.apache.org/jira/browse/EMAIL-163?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17951456#comment-17951456 ]
Siegfried Goeschl edited comment on EMAIL-163 at 5/14/25 7:20 PM: ------------------------------------------------------------------ Hi [~mkomko] , sorry for going dark but I became an "Emeritus ASF Member" some time ago since I can't spend any meaningful amount of time to open source activities. According to [https://javaee.github.io/javamail/OAuth2] you just need to pass an OAuth2 token instead of the password but I'm pretty sure this is not the end of the story. So my working assumption is that something like this should work {code:java} email.setAuthenticator(new DefaultAuthenticator(username, token); {code} Would it be possible to get in touch with me? Maybe we can do a remote debugging session ... was (Author: sgoeschl): Hi [~mkomko] , sorry for going dark but I became an "Emeritus ASF Member" some time ago since I can't spend any meaningful amount of time to open source activities. According to [https://javaee.github.io/javamail/OAuth2] you just need to pass an OAuth2 token instead of the password but I'm pretty sure this is not the end of the story. So my working assumption is that something like this should work {code:java} email.setAuthenticator(new DefaultAuthenticator(username, token); {code} > Support for OAuth2 authentication > --------------------------------- > > Key: EMAIL-163 > URL: https://issues.apache.org/jira/browse/EMAIL-163 > Project: Commons Email > Issue Type: New Feature > Affects Versions: 1.4 > Reporter: Guillaume Grossetie > Assignee: Siegfried Goeschl > Priority: Major > Labels: OAuth2 > > {quote} > Starting with JavaMail 1.5.5, support for OAuth2 authentication is built-in > and no longer requires SASL (although the SASL OAuth2 support continues to > work). > {quote} > https://java.net/projects/javamail/pages/OAuth2 > It would be great if commons email could provide an API to support OAuth2 > authentification. > The following code should be integrated in {{Email.getMailSession}}: > {code} > if (isOAuth2Authentication()) { > props.put("mail.smtp.auth.mechanisms", "XOAUTH2"); > } > {code} > Or a generic solution: > {code} > if (this.authMechanisms != null) { > props.put("mail.smtp.auth.mechanisms", this.authMechanisms); > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)