简体   繁体   English

MS Exchange“现代身份验证”支持 java 的 EMAIL

[英]MS Exchange "modern authentication" support for EMAIL for java

I have been asked to upgrade the java code to support modern authentication (which currently supports basic auth) for MS Exchange used to send email from server.我被要求升级 java 代码以支持用于从服务器发送 email 的 MS Exchange 的现代身份验证(目前支持基本身份验证)。 I have clientid, tenantid, and client secret already with me.我已经有了客户端 ID、租户 ID 和客户端密码。 I have scrolled and went thru many articles on web, I got the understanding of oAuth2 and flow of what needs to be done, but I am unable to actually find the java libraries for the purpose.我已经滚动并浏览了许多关于 web 的文章,我了解了 oAuth2 和需要做什么的流程,但我实际上无法为此目的找到 java 库。 Any help, tutorial links or sample code will help.任何帮助、教程链接或示例代码都会有所帮助。

Went thru this article: https://javaee.github.io/javamail/OAuth2#:~:text=Starting%20with%20JavaMail%201.5.,use%20only%20the%20XOAUTH2%20mechanism .通过这篇文章: https://javaee.github.io/javamail/OAuth2#:~:text=Starting%20with%20JavaMail%201.5.,use%20only%20the%20XOAUTH2% but the link for ms server does not proivde require info但是 ms 服务器的链接不提供需要信息

The lib for ews is ews-java-api The example how to use Modern flow: ews 的 lib 是ews-java-api如何使用 Modern flow 的示例:

  1. Get token with scope - https://outlook.office365.com/EWS.AccessAsUser.All使用 scope - https://outlook.office365.com/EWS.AccessAsUser.All获取令牌
  2. Add the token to headers:将令牌添加到标头:
var service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.setUrl(URI.create("https://outlook.office365.com/ews/exchange.asmx"));
service.getHttpHeaders().put("Authorization", "Bearer " + token);

See the docs: https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate-an-ews-application-by-using-oauth请参阅文档: https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-authenticate-an-ews-application-by-using-oauth

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM