2
votes

Here's a screenshot of the API call in Postman. I'm getting the token and using it here.

enter image description here

I'm getting 401 Unauthoized with no response. Is it because of the permissions within the app registration?

I've the following permissions for Power BI Service and Windows Azure Active Directory: enter image description here enter image description here

But when I click on grant permissions I get the error:

enter image description here

So, does the admin need to grant permission for this app (Web app / API) for it to work?

UPDATE

This is the API I call to get the access token.

https://login.microsoftonline.com/parkercorp.onmicrosoft.com/oauth2/token

POST BODY:

client_id: app_registration_clientId
client_secret: app_registration_client_secret
grant_type: client_credentials
resource: https://analysis.windows.net/powerbi/api
scope: openid

This is the decoded token as suggested by Tom Sun.

enter image description here

2

2 Answers

0
votes

When you have a permission checked that says "Requires Admin", then yes, you need an admin to click Grant Permissions. However, I don't think the two you have selected in your screenshot above are necessary for what you're trying to do. Try unchecking them, granting permissions, and running the request again.

0
votes

So, does the admin need to grant permission for this app (Web app / API) for it to work?

The root reason for granting permission failed is that you need admin consent that your admin can do it.

As you want to access the powerBI resource, so just need to check PowerBI service premission.

But cccording to your screenshot, you are trying to call Get Dashboard API.

GET https://api.powerbi.com/v1.0/myorg/dashboards/{dashboardKey}

Based on the document, required scope is Dashboard.ReadWrite.All or Dashboard.Read.All. It is no need to require admin consent.

enter image description here

401 error means that no permission to access the resource.

We could use the JWT.io to to decode the token to check the aud and permissions.

enter image description here

If possible, you could add the code how to get the token that will be more helpful.