最近,我们已经完成了新的应用注册,与之前的应用注册完全相同。并且,我们陷入了一个问题,使用针对Office 365 API的Microsoft.Office365.Discovery v1.0.22 NuGet服务发现库。
引发了类型为“ Microsoft.Office365.Discovery.DiscoveryFailedException”的异常 在Microsoft.Office365.Discovery.DiscoveryClient.d__4.MoveNext()\ r \ n --- 从上一个引发异常的位置开始的堆栈跟踪结束--- \ r \ n
在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n
在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n
在Microsoft.Office365.Discovery.DiscoveryClient.d__14.MoveNext()\ r \ n --- 从上一个引发异常的位置开始的堆栈跟踪结束--- \ r \ n
在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n
在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n
在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\ r \ n
代码
var result = new Dictionary<String, AuthenticationResult>();
ClientCredential credential = new ClientCredential(clientId, clientSecret);
AuthenticationContext authContext = new AuthenticationContext(string.Format("{0}/{1}", "https://login.windows.net", tenantId));
//authenticate discovery so we can auth all endpoints
var discoveryAccess = authContext.AcquireTokenByAuthorizationCode(authorizationCode, redirectUri, credential, m_sDiscoverySvcResourceId);
result.Add(m_sDiscoverySvcResourceId, discoveryAccess);
//discover endpoints
try
{
DiscoveryClient discClient = new DiscoveryClient(m_uriDiscoverySvcEndpointUri, () => { return discoveryAccess.AccessToken; });
var services = await discClient.DiscoverCapabilitiesAsync();
foreach (var service in services)
{
var srvId = service.Value.ServiceResourceId;
result[srvId] = discoveryAccess;
}
}
catch (DiscoveryFailedException e)
{
Debugger.Break();
}
return result;
相同的代码可以与先前创建的应用程序注册一起正常运行。感谢任何帮助