Era*_*nli 5 azure azure-active-directory powerbi powerbi-embedded power-bi-report-server
我已经创建了我的应用程序并通过https://dev.powerbi.com/Apps注册为 Native。在 Azure 中,我添加了自己的全局管理员用户,将自己注册为应用程序管理员,并授予了所有 Power BI API 权限。我创建了一个工作区,给自己添加了一个管理员用户。在我的工作区上传了 Power BI 报告。当我在浏览器上时效果很好。
我正在尝试使用 ASP.NET 4.61 MVC 连接我的报告。我的凭据、用户名和密码有效,因此下面的代码没有问题:
var credential = new UserPasswordCredential(Username, Password);
// Authenticate using created credentials
var authenticationContext = new AuthenticationContext(AuthorityUrl);
var authenticationResult = await authenticationContext.AcquireTokenAsync(ResourceUrl, ApplicationId, credential);
if (authenticationResult == null)
{
result.ErrorMessage = "Authentication Failed.";
return View(result);
}
var tokenCredentials = new TokenCredentials(authenticationResult.AccessToken, "Bearer");
Run Code Online (Sandbox Code Playgroud)
但是,我收到错误:在workspaceId 与我的工作区匹配的Status: Unauthorized (401) 行上。GetReportsInGroupAsync(Workspaceid);
// Create a Power BI Client object. It will be used to call Power BI APIs.
using (var client = new PowerBIClient(new Uri(ApiUrl), tokenCredentials))
{
// Get a list of reports.
var reports = await client.Reports.GetReportsInGroupAsync(WorkspaceId);
...
}
Run Code Online (Sandbox Code Playgroud)
因此,由于未经授权错误,我无法访问我的工作区中的报告,并且我无法通过它。我如何授权自己,我已经在 AAD 中作为全局管理员,将自己添加为应用程序所有者,并且在工作区中我已经注册为管理员。
我在下面找到了这个主题,但答案没有解决我的问题:未经授权的错误 401 for power reports embedding
遵循此指南,也不起作用:https ://learn.microsoft.com/en-us/power-bi/developer/register-app
任何帮助,将不胜感激。
| 归档时间: |
|
| 查看次数: |
7187 次 |
| 最近记录: |