如何使用 OAuth 进行身份验证以访问 EWS API [英] How to authenticate with OAuth to access EWS APIs
问题描述
我的网络服务目前正在进行基本的用户名/密码验证,以便订阅交换用户以接收如下事件(如新邮件事件等):
My web service is currently doing basic username/password authentication in order to subscribe the exchange user for receiving the events (like new mail event etc) like below:
var service = new ExchangeService(exchangeVersion)
{
KeepAlive = true,
Url = new Uri("some autodiscovery url"),
Credentials = new NetworkCredential(username, password)
};
var subscription = service.SubscribeToPushNotifications(
new[] { inboxFolderFoldeID },
new Uri("some post back url"),
15,
null,
EventType.NewMail,
EventType.Created,
EventType.Deleted,
EventType.Modified,
EventType.Moved,
EventType.Copied);
现在,我应该替换身份验证机制以使用 OAuth 协议.我看到了一些示例,但所有示例似乎都在谈论对客户端进行身份验证(https://msdn.microsoft.com/en-us/library/office/dn903761%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396) 但我无法找到如何使用 OAuth 协议验证交换用户的示例.任何代码示例都会有很大帮助.谢谢.
Now, I am supposed to replace the authentication mechanism to use OAuth protocol. I saw some examples but all of them seem to be talking about authenticating the client (https://msdn.microsoft.com/en-us/library/office/dn903761%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396) but nowhere I was able to find an example of how to authenticate an exchange user with OAuth protocol. Any code sample will help a lot. Thanks.
推荐答案
以防有人仍在努力使其正常工作.我们需要在 azure 门户上为应用程序上传证书清单,然后使用相同的证书对客户端进行身份验证以获取访问令牌.更多详情请参见:https://blogs.msdn.microsoft.com/exchangedev/2015/01/21/building-daemon-or-service-apps-with-office-365-mail-calendar-and-contacts-apis-oauth2-client-credential-flow/
In case someone is still struggling to get it to work. We need to upload a certificate manifest on azure portal for the application and then use the same certificate to authenticate the client for getting the access token. For more details please see: https://blogs.msdn.microsoft.com/exchangedev/2015/01/21/building-daemon-or-service-apps-with-office-365-mail-calendar-and-contacts-apis-oauth2-client-credential-flow/
这篇关于如何使用 OAuth 进行身份验证以访问 EWS API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!