0
votes

I want to embed a report in the customer's application using the service principal. I am able to generate an access token but when I am using that token to generate an embed token, I got 403 forbidden.

I generate access token as follow:

enter image description here

and for embed token I follow below documentation :

https://docs.microsoft.com/en-us/rest/api/power-bi/embedtoken/reports_generatetokenforcreateingroup

Can you please guide me to solve this problem.

1

1 Answers

0
votes

Users get 403 Forbidden responses because of below mentioned reasons:

  • Azure AD Service Principal application not added in workspace with at least member privilege.
  • Permission for Service Principal to use Power BI APIs is not enabled in Power BI Admin portal.

Please refer Add Service Principal application to workspace docs to complete above mentioned steps.

Even after adding Service Principal Application to workspace, Embed Token - Reports GenerateTokenForCreateInGroup API gives 403 Forbidden requests, then go through the below steps.

For generating access token, we need to specify target resource that we are going to use the token with (resource URI).

Below screenshot show generating access token for Service Principal Authentication with resource URI. Generate Access Token using v1 endpoint

Alternatively, you can use v2.0 endpoint for generating access token.

Refer below screenshot to use v2.0 endpoint: Generate Access Token using v2 endpoint

The access token from response can be further used to generate embed token as shown below: Generate Embed Token

Please refer these docs for more information about v2 endpoint:

Note: While generating embed token, pass request body as shown in Embed Token - Reports GenerateTokenForCreateInGroup.