【发布时间】:2018-02-28 19:31:43
【问题描述】:
我正在尝试按照来自here 的示例项目和教程,在 WPF 应用程序中嵌入示例 Power BI 仪表板。当我启动应用程序时,我必须输入我的密码来验证我自己,当它尝试使用 getAppWorkspacesList() 获取我的 Power BI 工作区列表时,我收到此错误消息
Microsoft.Rest.HttpOperationException: '操作返回无效 状态码'未授权''
有人可以帮忙指出为什么会发生这个错误吗?我试图查看错误的详细信息,但我不明白是什么导致了这个问题。我能够毫无问题地将仪表板嵌入到 .Net Web App 中,因此我认为问题不在于我的 Power BI 或 Azure Directory 帐户。
private static string aadInstance = ConfigurationManager.AppSettings["ida:AADInstance"];
private static string tenant = ConfigurationManager.AppSettings["ida:Tenant"];
private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"];
Uri redirectUri = new Uri(ConfigurationManager.AppSettings["ida:RedirectUri"]);
private static string authority = String.Format(CultureInfo.InvariantCulture, aadInstance, tenant);
private static string graphResourceId = ConfigurationManager.AppSettings["ida:ResourceId"];
private AuthenticationContext authContext = null;
TokenCredentials tokenCredentials = null;
string Token = null;
string ApiUrl = "https://api.powerbi.com";
public MainWindow()
{
InitializeComponent();
TokenCache TC = new TokenCache();
authContext = new AuthenticationContext(authority, TC);
}
private void getAppWorkspacesList()
{
using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials))
{
appWorkSpacesList.ItemsSource = client.Groups.GetGroups().Value.Select(g => new workSpaceList(g.Name, g.Id));
}
}
【问题讨论】:
标签: c# wpf azure-active-directory powerbi-embedded