由于 Microsoft 阻止了基本身份验证,我必须重建我的应用程序,该应用程序可以从 O365 中的邮箱下载所有符合特定条件的附件。我想通过使用令牌的仅应用程序身份验证方法来实现它
我的应用程序在 AD 中注册,我能想到的所有权限都已添加并由全局管理员授予。
我已经设置并添加了 appID、clientSecret、tenantID 等
这是我当前的代码,有人可以指导我怎么做吗
exch.ExchangeService exchange = null; 字符串名称 = ConfigurationManager.AppSettings["AccountName"].ToString(); 字符串密码 = ConfigurationManager.AppSettings["AccountPassword"].ToString(); //System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateServerCertificate); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 交换=新exch.ExchangeService(exch.ExchangeVersion.Exchange2010_SP1) { Credentials = new exch.WebCredentials(Name, Password, "EMEA"), -- EMEA - 域名 url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"), //exchange.TraceEnabled = true; UseDefaultCredentials = false, //超时= 1000, EnableScpLookup = 假 };
exch.Folder inbox = exch.Folder.Bind(exchange, exch.WellKnownFolderName.Inbox);
//Console.WriteLine("The folder name is " + inbox.DisplayName.ToString());
在仅应用程序身份验证标题下