I'm trying to access datasets in PBI, but I can't get the correct permissions
I created an application in Microsoft Entra ID To get a token I make a request:
POST /{{tenantId}}/oauth2/v2.0/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded
Content-Length: ...
client_id={{clientId}}
&grant_type=client_credentials
&scope=https://analysis.windows.net/powerbi/api/.default openid profile offline_access
&client_secret={{clientSecret}}
I receive a response with a token:
{
"token_type": "Bearer",
"expires_in": 3599,
"ext_expires_in": 3599,
"access_token": "ey...Cw"
}
After this, I make a request to get dataset:
GET /v1.0/myorg/groups/{{workspaceId}}/datasets/{{datasetId}} HTTP/1.1
Host: api.powerbi.com
Authorization: Bearer ey...Cw
And I receive a 401 response:
{
"error": {
"code": "PowerBINotAuthorizedException",
"pbi.error": {
"code": "PowerBINotAuthorizedException",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
}
}
Following permissions are specified for the app in Microsoft Entra ID: Microsoft Entra ID App API Permissions
You don't need, and shouldn't set any app permissions in Entra ID.
You do need to grant the service principal rights in the workspace.