Geir Forsmo
Geir Forsmo

Reputation: 149

Problem with Python Web App accessing Power BI embedded report

I have trouble showing a power bi report in Power BI service suing a Python Web App. I got this error message:

Error Details:

400 Bad Request: Error while retrieving Embed token
Bad Request: {"error":{"code":"InvalidRequest","message":"Creating embed token for accessing dataset de376430-e631-4dbe-8722-2c9112f6e0ca requires effective identity to be provided"}}
RequestId: 052b6e05-8a39-408c-94d7-fe7091010d29

I have followed all steps in this article https://www.alphabold.com/power-bi-embedded-implementation-using-service-principal-and-python/ which is creating a Power BI embedded solution where I have created a Service principal service user, which I have put into a security group and this service principal is also an admin in the power bi workspace. I have tested this solution and a dummy report without dataset connection is showing up.

In the real test I have using a power bi report that has a dataset to an on prem SQL server database through a data gateway. The report itself is working inside the power bi service, but when I try to make it show up in the web app, the error message comes up.

So I think it must have something to do with the data gateway and the connection to the on prem dataset. I have heard somewhere that I need to add the data gateway user to the SQL database.

Upvotes: 0

Views: 1143

Answers (2)

Sourav Singh Gehlot
Sourav Singh Gehlot

Reputation: 21

Just for your information, if you are using Django version >= 4.1, they have introduced SecurityMiddleware that disables third-party cookies. Consequently, you may encounter issues with the Power BI embedded iframe. I struggled with this.

To allow third-party cookies, you may need to configure SECURE_CROSS_ORIGIN_OPENER_POLICY in settings.

Upvotes: 1

Rahul Roy
Rahul Roy

Reputation: 397

This error can be caused by many different factors, such as:

  • Authentication Token is expired

  • Dataset doesn't support effective identity

  • Username wasn't provided

  • Role wasn't provided

  • DatasetId wasn't provided

  • User doesn't have the correct permissions

Try these steps to see which one it is:

  • Make sure the Authentication Token is refreshed
  • Execute get dataset. Is the property IsEffectiveIdentityRequired true?
  • Username is mandatory for any EffectiveIdentity.
  • If IsEffectiveIdentityRolesRequired is true, Role is required.
  • DatasetId is mandatory for any EffectiveIdentity.
  • For Analysis Services, the master user must be gateway admin.

Reference:

https://learn.microsoft.com/power-bi/developer/embedded/embedded-troubleshoot#what-is-the-difference-between-application-object-id-and-principal-object-id

Upvotes: 1

Related Questions