Forum Discussion
PowerBINotAuthorizedException :: Embed report via access token
I have requirement to access BI reports.. by programmatically deriving the access token so that users doesn't have to signup in order to view the reports.
I followed the link
https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-sample-for-customers?tabs=python.
to embed the report in my application.
I downloaded the sample app for python and executed it.. I get the access token but accessing report gives error
Error Details:
401 Unauthorized: Error while retrieving Embed URL
Unauthorized: {"error":{"code":"PowerBINotAuthorizedException","pbi.error":{"code":"PowerBINotAuthorizedException","parameters":{},"details":[],"exceptionCulprit":1}}}
RequestId: c16c2dff-d7ef-4b4e-b0ce-1f9c67f9ae9a
In accepted solution of https://powerusers.microsoft.com/t5/Building-Flows/Power-BI-Connector-PowerBINotAuthorizedException/td-p/746073 says to use Premium capacity for the report/workspace
Before moving to production , I wanted to test the solution .. is there any way to make this works without creating capacity.
Or am I missing any other configuration apart from what is mentioned in the above links..
4 Replies
- ibarrau
Super User
Hi. That means that your App registered doesn't have the permission to do that action. Be sure that you have all the permissions for the App. When login with Service Principal that's all.
https://docs.microsoft.com/en-us/power-bi/developer/embedded/generate-embed-token#access-level
If you are login in with an Azure AD Account then don't forget that "Your master user or an administrator has to grant consent for your app to access Power BI REST API permissions (also known as scopes). For example, Report.ReadWrite.All."
I hope that helps,
- mamta-bmoreFrequent Visitor
Thanks ibarrau for quick reply.. By default I have granted all API permissons
and Grant Admin consent is also selected.
- ibarrau
Super User
Ok, then there might be two possible reasons:
- Wrong group ID
- Unauthorized group
Be sure that the url is ok and that the Service Principal or User has admin permission on the workspace.
- mamta-bmoreFrequent Visitor
I think I am able to resolve the problem..
In addition to API permissions. we have to allow public client flows.
Its under [app registration name] > Authentication > Advanced Settings
Also I have change Authentication mode from 'ServicePrincipal' to 'masteruser'