创建DiscoveryClient对象时

创建DiscoveryClient对象时

本文介绍了创建DiscoveryClient对象时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在创建DiscoveryClient对象时遇到问题。我试图通过授予所有权限来解决这个问题,然后生成秘密,但我仍然是相同的例外。


 public string discoveryId =" https://api.office.com/discovery/" ;; 

public string cmmAth =" https://login.windows.net/Common" ;;



公共异步任务< OutlookServicesClient> EnsureClientCreatedAsync()
{
try
{
string authority = cmmAth;
_authenticationContext = new AuthenticationContext(authority);
DiscoveryClient discoCli = new DiscoveryClient(async()=> await GetTokenHelperAsync(_authenticationContext,discoveryId));
CapabilityDiscoveryResult discoResult = await discoCli.DiscoverCapabilityAsync(" Calendar");
变种outlookCli =新OutlookServicesClient(discoResult.ServiceEndpointUri,异步()=>等待GetTokenHelperAsync(_authenticationContext,discoResult.ServiceResourceId));
返回outlookCli;

}
catch(AdalException e)
{
MessageBox.Show(e.ToString());
如果(_authenticationContext = NULL和放大器;!&安培;!_authenticationContext.TokenCache = NULL){
_authenticationContext.TokenCache.Clear();
}
返回null;
}
}

public async任务< string> GetTokenHelperAsync(AuthenticationContext context,string resourceId)
{
string accessToken = null;
AuthenticationResult result = null;
ClientCredential cliCred =新ClientCredential(QUOT; XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX"," yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy = QUOT);
result = await context.AcquireTokenAsync(resourceId,cliCred);
accessToken = result.AccessToken;
返回accessToken;
}

我的AdalException是


 AADSTS70001:在目录api.office.com中找不到标识符为xxxxx-xxxx-xxxx-xxx-xxxxx的应用程序




thx任何帮助


Maciej 






解决方案


这篇关于创建DiscoveryClient对象时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 00:16