PowerBIClient没有任何值



我正在尝试使用powerbi SDk读取powerbi报告。我得到了正确的访问令牌(在poster中测试(。为TokenCredentials传递相同的访问令牌。但是在_powerBIClient中没有得到任何值。它没有任何价值。我正在使用以下代码。

var functionCred = new Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential(_configuration[BotConfigurationEnum.FunctionClientId.GetDescription()], _configuration[BotConfigurationEnum.FunctionClientSecret.GetDescription()]);
var userAssertion = (!string.IsNullOrWhiteSpace(token)) ? new Microsoft.IdentityModel.Clients.ActiveDirectory.UserAssertion(token, "urn:ietf:params:oauth:grant-type:jwt-bearer") : null;
var context = new AuthenticationContext("https://login.microsoftonline.com/{tenentid}");
var res = await context.AcquireTokenAsync("https://analysis.windows.net/powerbi/api",
functionCred, userAssertion);
var tokenCredentials = new TokenCredentials(res.AccessToken, "Bearer");
var _powerBIClient = new PowerBIClient(new Uri("https://api.powerbi.com/"), tokenCredentials);
var pbiReport = _powerBIClient.Reports.GetReport(reportId);

我的代码中有小的更正。。我已经在新的Uri中删除了"/",它起作用了。我知道这很傻。。

var _powerBIClient = new PowerBIClient(new Uri("https://api.powerbi.com"), tokenCredentials);

最新更新