Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
tripleacoder
Helper I
Helper I

Power Bi REST API - 401 Authorization error when using app secret

I have a console app that uses the REST API to get a dataset (and later add rows to it). This works when I supply my own user/password credentials.

 

Now I have registered the app as a Web/API app in order to use an app key/secret instead. I can get a token, but when I make the same REST call I get 401 Unauthorized.

 

I have given the app the following Application permissions in Power BI Service (is this needed?):

Read and write all content in tenant

View all content in tenant

These permissions have been granted by an Azure Administrator.

 

In addition to the Delegated permissions that worked with user authentication:

Read and write all Datasets

View all Datasets

 

I have decode the two tokens.

The token for app key autentication contains this:

"roles": [
"Tenant.ReadWrite.All",
"Tenant.Read.All"
],

 

while the token for user based authentication contains this:

"scp": "Dataset.ReadWrite.All Workspace.ReadWrite.All",

 

What am I missing..?

1 ACCEPTED SOLUTION

Hi @tripleacoder,

 

As far as I know, the permissions of Power BI are all based on the users. So an App can't act as a user. Please refer to developer/power-bi-permissions where all the descriptions have "user". 

Regarding "Tenant.ReadWrite.All", the documentation above also has a description. Actually, these permissions only can retrieve the profiles rather than data. Please refer to admin/reports_getreportsasadmin.

One simple proof we can see is that even an admin can't access all the App workspaces. The data is the precious asset of a company. I think this is reasonable.

 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

22 REPLIES 22
Anonymous
Not applicable

Most organization have app registrations locked down pretty tight. I am not familiar with that tool for app registration, but I don't imagine it is meant to be a workaround for corporate security restrictions, and I would expect it to fail for most users within most Azure tenants.

Anonymous
Not applicable

HI 

 

I am getting a same error Failed to load resource: the server responded with a status of 401 when I try to open dashboard URL in new tab https://app.powerbi.com/dashboardEmbed?dashboardId=100114d8-9c7c-4ae1-b1d5-291603b4f22c&config=eyJjb...

 

It works fine on localhost sample dashboard app (C# visual studio 2017)

I am also getting this error on console for https://api.powerbi.com/powerbi/metadata/refreshusermetadata

When i open this link it shows message. See the screenshot below :

 

service.png

 

The dashboard URL should also work on a new tab too because I want to use this link into another website 

 

Please help me, I am trying to find a solution for this now for two days.

 

Thanks in advance.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors