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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
eddywijaya
Frequent Visitor

Getting PowerBI embed Access Token via REST

Hi everyone,

I'm creating a PowerBI embedded App following this Sample :

https://github.com/Microsoft/PowerBI-Developer-Samples/tree/master/User%20Owns%20Data/integrate-dash...

 

But i'd like to use a service account, so the user can access the dashboard without signing in to Microsoft.

So i tried to get the access token from : https://login.windows.net/common/oauth2/token

This is the example screenshot (i'm using Postman) POST image, and i'm getting this error :

 

{
    "error": "invalid_grant",
    "error_description": "AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password\r\nTrace ID: 3651fe1c-cfec-45a9-bef4-1aa7b0140400\r\nCorrelation ID: 1f661718-738e-4654-97ce-b8388ac01401\r\nTimestamp: 2018-04-27 02:32:33Z",
    "error_codes": [
        70002,
        50126
    ],
    "timestamp": "2018-04-27 02:32:33Z",
    "trace_id": "3651fe1c-cfec-45a9-bef4-1aa7b0140400",
    "correlation_id": "1f661718-738e-4654-97ce-b8388ac01401"
}

I'm sure that i have given the correct credential (username, password, client_id, client_secret) because they're working in the .NET sample project.

There is no symbol on the password, only alphabetical and number.

 

1 REPLY 1
Anonymous
Not applicable

Hi @eddywijaya,

 

Maybe this previous post solves your problem?

Otherwise, could you try something like this using .NET code in order to see that it works? Does it returns a token? 

With this token you can then make calls to the PowerBI REST API using Fiddler/Postman.

Note that the AAD application should be a native app.

 

using Microsoft.IdentityModel.Clients.ActiveDirectory;

/// <summary> /// Returns an AccessToken for the PowerBi service. /// </summary> private async Task<string> GetPowerBiAccessToken() { var powerBiAccountCredentials = new UserCredential("PowerBIAADUserName", PowerBIAADUserPassword"); var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/authorize/"); var authenticationResult = await authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", "PowerBIAADAppId", powerBiAccountCredentials); return authenticationResult.AccessToken; }

This link about authenticate a client app may be helpful.

 

Hope this helps.

 

Regards,

 

Thanos

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.