public async Task<ActionResult> GetReportEmbedded() { // Create a user password credentials. var accessToken = await GetTokenCredentials(); var tokenCredentials = new TokenCredentials(accessToken, "Bearer"); // Generate Embed Token. //using (FileStream fileStream = new FileStream(powerBi.Value.pbixPath, FileMode.Open, FileAccess.Read)) using (var client = new PowerBIClient(new Uri(powerBi.Value.ApiUrl), tokenCredentials)) using (Task<Group> tableTalkGroup = client.Groups.GetGroupsWithHttpMessagesAsync() .ContinueWith(task => task.Result.Body.Value.First(group => @group.Name == "*** group name ***"))) using (Task<Report> reportTask = client.Reports.GetReportsInGroupWithHttpMessagesAsync((await tableTalkGroup).Id).ContinueWith(task => task.Result.Body.Value.First(report => report.Name == "Power BI Template"))) { Dictionary<string, List<string>> headerDictionary = new Dictionary<string, List<string>>(); headerDictionary.Add("roles", new List<string>{ "***custom role***" }); var tokenResponse = await client.Reports.GenerateTokenInGroupWithHttpMessagesAsync( (await tableTalkGroup).Id, (await reportTask).Id, new GenerateTokenRequest(accessLevel: "view"), headerDictionary, CancellationToken.None); // Generate Embed Configuration. var embedConfig = new EmbedConfig() { EmbedToken = tokenResponse.Body, EmbedUrl = (await reportTask).EmbedUrl, Id = (await reportTask).Id }; return View(embedConfig); } }
i have uploaded a pbix file with custom role now i am trying to apply this role to the embedded report but i don't know how to add the custom header properly to add my request for the role. the ONLY reference i could find to this is here https://docs.microsoft.com/en-ca/azure/power-bi-workspace-collections/app-token-flow
but it references the deprecated "Power BI Workspace Collections". i keep seeing the customHeader Parameter in a lot of the calls i use but i don't know how to properly use it.
i am trying to use this for my company's multi tenant solution and i want make sure customers only have access to their data. i think im going about this in the right direction but if not please let me know.