微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用AcquireTokenAsync函数无法获取Power BI令牌

如何解决使用AcquireTokenAsync函数无法获取Power BI令牌

我的ASP.NET MVC项目之一使用Power BI报表集成到页面中。在控制器中,我使用此代码获取令牌。

var credential = new UserPasswordCredential("USERNAME","PASSWORD");
var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/authorize/");
var authenticationResult = await authenticationContext.AcquiretokenAsync("https://analysis.windows.net/powerbi/api","APPLICATION_ID",credential).ConfigureAwait(false);

代码到达AcquiretokenAsync函数时,它将引发此异常。感谢您的支持

Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException:unkNown_error:未知错误> System.Threading.Tasks.TaskCanceledException:任务被取消。 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在Microsoft.IdentityModel.Clients.ActiveDirectory.HttpClientWrapper.d__30.MoveNext() 内部异常堆栈跟踪结束 在Microsoft.IdentityModel.Clients.ActiveDirectory.AdalHttpClient.d__21 1.MoveNext() End of stack trace from prevIoUs location where exception was thrown at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.IdentityModel.Clients.ActiveDirectory.AdalHttpClient.<GetResponseAsync>d__21 1.MoveNext() 从之前引发异常的位置开始的堆栈跟踪结束 在System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在Microsoft.IdentityModel.Clients.ActiveDirectory.AdalHttpClient.d__20 1.MoveNext() End of stack trace from prevIoUs location where exception was thrown at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.IdentityModel.Clients.ActiveDirectory.UserRealmdiscoveryResponse.<CreateBydiscoveryAsync>d__24.MoveNext() End of stack trace from prevIoUs location where exception was thrown at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquiretokenNonInteractiveHandler.<PretokenRequest>d__5.MoveNext() End of stack trace from prevIoUs location where exception was thrown at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquiretokenHandlerBase.<RunAsync>d__55.MoveNext() End of stack trace from prevIoUs location where exception was thrown at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquiretokenCommonAsync>d__52.MoveNext() End of stack trace from prevIoUs location where exception was thrown at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions.<AcquiretokenAsync>d__0.MoveNext() End of stack trace from prevIoUs location where exception was thrown at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() 在D:\ DashboardController.cs:line 317中的Manpower.TicketTracking.Web.Areas.TicketsManagement.Controllers.DashboardController.d__15.MoveNext() 错误代码:unkNown_error 状态码:0

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。