gpt4 book ai didi

c# - Power Bi 管理的 Azure AD 代表流程

转载 作者:行者123 更新时间:2023-12-03 04:14:31 27 4
gpt4 key购买 nike

我成功设置了“Azure AD 代表流程”,我的 Web api 安全操作调用和 ms graph api 调用也正常工作。不,我添加了更多与 power bi 相关的补助金。我想从 Web api 读取/写入工作区/报告等我试过了:

string[] scopes = { "Capacity.Read.All", "Capacity.ReadWrite.All",
"Content.Create", " Dashboard.Read.All", " Dashboard.ReadWrite.All",
"Data.Alter_Any", "Dataset.Read.All", "Dataset.ReadWrite.All", "Group.Read", "Group.Read.All",
"Metadata.View_Any", "Report.Read.All", "Report.ReadWrite.All", "Tenant.Read.All",
"Workspace.Read.All", "Workspace.ReadWrite.All"};
string accessToken = await _tokenAcquisition.GetAccessTokenOnBehalfOfUser(HttpContext, scopes); // error
var tokenCredentials = new TokenCredentials(accessToken, "Bearer");
using (var client = new PowerBIClient(new Uri(_powerBiConfig.ApiUrl), tokenCredentials))
{
...
}

但是 GetAccessTokenOnBehalfOfUser 返回

AADSTS70011: The provided request must include a 'scope' input parameter. The provided value for the input parameter 'scope' is not valid.

最佳答案

我自己得到的。

下面的代码演示了如何检索所有 Power bi 工作区

public async Task<string> Groups()
{
string[] scopes = { "https://analysis.windows.net/powerbi/api/Dataset.Read.All"};
try
{
string accessToken = await _tokenAcquisition.GetAccessTokenOnBehalfOfUser(HttpContext, scopes);
var tokenCredentials = new TokenCredentials(accessToken, "Bearer");
using (var client = new PowerBIClient(new Uri(_powerBiConfig.ApiUrl), tokenCredentials))
{
return JsonConvert.SerializeObject(client.Groups.GetGroups().Value, Formatting.Indented);
}
}
catch (Exception exc)
{
return string.Empty;
}
}

关于c# - Power Bi 管理的 Azure AD 代表流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54289542/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com