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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ekimakIA
Frequent Visitor

PBI Access Token API

Hi,

 

I'm  trying to fetch pbi access token with this below api but I'm getting issue while executing this API.

 

API : https://token.docs.microsoft.com/accesstokens

 

In the header I'm passing powerbi username and password. But still I'm not getting pbi access token.

1 ACCEPTED SOLUTION

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.All

Check your delegated permission in the app registered to validate that.

I hope that make sense


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

Happy to help!

LaDataWeb Blog

View solution in original post

3 REPLIES 3
ekimakIA
Frequent Visitor

Hi,

 

Using this access token URL "URL: https://login.microsoftonline.com/common/oauth2/token" Im getting the access token but when I pass this token in "Export Report In Group" API. We are getting unauthorized.

This authentication is not working for Report API. 

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.All

Check your delegated permission in the app registered to validate that.

I hope that make sense


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

Happy to help!

LaDataWeb Blog

ibarrau
Super User
Super User

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,


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

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.