Wednesday, June 7, 2023

Call Power BI API from .net Core API with Delegated Permissions

 If you want to consume Power BI API from .net Core API there are multiple ways of doing it. 

1. Call with Delegated Permission. 

2. Call with Service Principle. 

Certain endpoints cannot be called with Service Principle. Like you want to get the list of reports that caller user has access too. In this case, you'll need to use Delegated Permission. 

In order to achieve this in ASP.NET Core API,  you need to do the following 


1. Register an App in Azure. 

2. Go to API Permissions and select the Delegated Permissions for Power BI Service. 

3. In your API, you need to inject the following. 


3. Pay attention to the method "GetAccessTokenForUserAsync" used to get the delegated access and the ClaimPrincipal is passed in the method. 

4. This will give you the token which you can use to call the Power BI API. 




No comments:

Post a Comment