Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Power Bi data protection - Access Token per report

Hi all,

 

I am using Power BI REST API and I am building an application that will pass the access token and embedUrl for the selected report. The data is downloaded automatically by the master user who has access to all reports. Clients can only view reports made available by master user.

One of the requirements is that the end-user (client) must have access only to the submitted report. In other words, modifying embedUrl should not allowed user to get access to another report / workspace.

From what I noticed, my implementation of getting access token gives access to all reports. Can it be changed so that the access token is per report or at least workspace?


Language C#

var tenantId = ...
var clientId = ...
var clientSecret = ...

var username = ...
var password = ...
var resource = "https://analysis.windows.net/powerbi/api";

var client = new RestClient($"https://login.microsoftonline.com/{tenantId}/oauth2/token");
var request = new RestRequest(Method.POST);

request.AddParameter("username", username, ParameterType.GetOrPost);
request.AddParameter("password", password, ParameterType.GetOrPost);
request.AddParameter("client_secret", clientSecret, ParameterType.GetOrPost);
request.AddParameter("client_id", clientId, ParameterType.GetOrPost);
request.AddParameter("resource", resource, ParameterType.GetOrPost);
request.AddParameter("grant_type", "password", ParameterType.GetOrPost);

var response = client.Execute(request);



My program is based on Power-Bi-Samples / .NET Core / Embed for your organisation

https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/.NET%20Core/Embed%20for%20your%20organization

Thanks in advance for your help

2 Replies