Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OAuth Auth for Gmail(and OAuth token based mail services) to avoid "less secure apps" #97

Open
Jacke opened this issue Mar 28, 2016 · 3 comments

Comments

@Jacke
Copy link

Jacke commented Mar 28, 2016

Hi. Is there have plans for developing https://java.net/projects/javamail/pages/OAuth2 this sort of auth? If anybody needs this feature I can start implementing it to play mailer on next week.

@Jacke Jacke changed the title OAuth Auth for GMAIL to avoid "less secure apps" OAuth Auth for Gmail(and OAuth token based mail services) to avoid "less secure apps" Mar 28, 2016
@ggrossetie
Copy link
Member

Hello @Jacke, this would be a great addition!

Behind the scene, play mailer plugin is using commons-email library which relies on Java mail 1.5.2.
If I read correctly OAuth2 Authentication is only available from Java mail 1.5.5 and later ?

I think you should open an issue to commons-email library to ask for an upgrade from 1.5.2 to 1.5.5: commons-email issue tracker

In the mean time you can experiment by excluding Java mail 1.5.2 dependency and adding explicitly a dependency on Java mail 1.5.5 in build.sbt

If you need help, feel free to ask 😄

@litts
Copy link

litts commented Mar 31, 2016

We are all looking forward to this enhancement.

@ggrossetie ggrossetie self-assigned this Apr 12, 2016
@ggrossetie
Copy link
Member

I think you can already do it by setting a system property: System.setProperty("mail.smtp.auth.mechanisms", "XOAUTH2");. The mail session is using system properties so this code is equivalent to:

Properties props = new Properties();
props.put("mail.smtp.auth.mechanisms", "XOAUTH2");
Session session = Session.getInstance(props);

As far as I know, only this property is required to switch to an OAuth2 authentication. I've also open on Commons Email because I think it's better to have a dedicated API to set the authentication mechanism: https://issues.apache.org/jira/browse/EMAIL-163

@litts @Jacke Could you please give it a try ? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants