Forum Discussion
PBI Access Token API
- 4 years ago
Hi. If you are getting a token that means the authentication is working perfect. The Unauthorized means that the ClientId doesn't have permission to do that.
Be sure that you have what you need. Each request in the API has in its document the scope. For example the scope for exporting report in group is:
Required scope: Report.ReadWrite.All or Report.Read.AllCheck your delegated permission in the app registered to validate that.
I hope that make sense
Hi. Assuming you are talking about the accessToken for the Power Bi API
https://docs.microsoft.com/en-us/power-bi/developer/automation/walkthrough-push-data-get-token
I can say you shouldn't sent that in the headers.
The access token is requested with a post method like this:
URL: https://login.microsoftonline.com/common/oauth2/token
Header: Content-Type: application/x-www-form-urlencoded
Body:
data = {
'grant_type': 'password',
'scope': 'openid',
'resource': 'https://analysis.windows.net/powerbi/api',
'client_id': power_bi_client_id,
'username': power_bi_username,
'password': power_bi_password
}
The last three items need to be changed. The clientid of your registered app, user and password. If you want to coonect with a service principal it might be a little different.
I hope that helps,