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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
DirkCoetzee
New Member

Power BI Embed error

 

Hi,

I am embedding a power BI report using the Javascript API.
The application is a jQuery and Javascript front-end and using a WCF Rest API.
I do the authentication in the Rest API, no integrated domain authentication, and it works as I am getting an access token,
which I then pass back to the front-end.

This has been working just fine, until yesterday when I started getting the below errors on the client (using Chrome).

Nothing changed on my end.

pbiCapture.PNG

 

Herewith is my embed code:
_accessToken is the object I got frm mny Rest API with the auth token.

var embedUrl = "https://app.powerbi.com/reportEmbed?reportId=" + _accessToken.reportid + "&groupId=" + _accessToken.groupid;
var models = window['powerbi-client'].models;
var config = {
type: 'report',
accessToken: _accessToken.token,
embedUrl: embedUrl
, settings: {
filterPaneEnabled: false,
navContentPaneEnabled: true,
background: models.BackgroundType.Transparent
}
};

// Grab the reference to the div HTML element that will host the report.
var reportContainer = document.getElementById('dashboard-content');

// Embed the report and display it within the div container.
var report = powerbi.embed(reportContainer, config);

And here is the C# to get the access token
Dictionary<string, object> tokendata = new Dictionary<string, object>();
try {
var credential = new UserPasswordCredential(PowerBIUsr,PowerBIPwd);

// Authenticate using created credentials
var authenticationContext = new AuthenticationContext("https://login.windows.net/common/oauth2/authorize/");
var authenticationResult = await Task.Run(() => authenticationContext.AcquireTokenAsync("https://analysis.windows.net/powerbi/api", PowerBIClientId.ToString(), credential));

if (authenticationResult == null) {
tokendata.Add("error", "{athfailed}");

} else {
tokendata.Add("reportid", this.Settings.PowerBIRepId);
tokendata.Add("groupid", this.Settings.PowerBIGrpId);
tokendata.Add("clientid", this.Settings.PowerBIClientId);
tokendata.Add("token", authenticationResult.AccessToken);
tokendata.Add("tokentype", authenticationResult.AccessTokenType);
tokendata.Add("tokenexpiry", authenticationResult.ExpiresOn);
}
} catch (Exception ex) {
tokendata.Add("error", "{athfailed}");
tokendata.Add("errorO", ex);
}
this.TokenData = tokendata;

Any help will be much appreciated

 

Kind regards

0 REPLIES 0

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.