I also posted this on the PowerBI Community but haven't gotten any traction: https://community.powerbi.com/t5/Developer/Auto-Generate-Embed-Token-using-Javascript-and-PHP/td-p/1316556
I have gotten my report working in test with a token generated using the Microsoft Embed Token - Generate Token (here https://docs.microsoft.com/en-us/rest/api/power-bi/embedtoken/generatetoken) and by using the PowerShell commands.
I got the formatting just right, changed some config and got it all working just how I wanted it on localhost.
To try figuring it out, I also used the automated Embedded setup via powerbi.com (here https://app.powerbi.com/embedsetup/appownsdata). I played around with the downloaded vs files which shows that generating the token on the fly is possible but it is all ASP.net and C# and I can't figure out how to convert it.
Now I am trying to get it deployed to production into my site which uses PHP and javascript.
Does anyone have some samples or anything where I could swap out my ReportId, GroupId, etc? Script kiddie style...
Here is what I am using that works perfectly, except for the expiring manually generated token:
<script src="./dist/powerbi.js"></script>
<div id="reportContainer" style="height: 1400px; width: 1000px;"></div>
<script>
// Get models. models contains enums that can be used.
var models = window['powerbi-client'].models;
// Embed configuration used to describe what and how to embed.
// This object is used when calling powerbi.embed.
// This also includes settings and options such as filters.
// You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
var embedConfiguration = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: '<manually generated token here>',
embedUrl: 'https://app.powerbi.com/reportEmbed',
id: '<report id here>',
permissions: models.Permissions.Read,
settings: {
// filterPaneEnabled: false,
// navContentPaneEnabled: true,
background: models.BackgroundType.Transparent,
panes:{
bookmarks: {
visible: false
},
fields: {
expanded: false
},
filters: {
expanded: false,
visible: false
},
pageNavigation: {
visible: true
},
selection: {
visible: false
},
syncSlicers: {
visible: false
},
visualizations: {
expanded: false
}
}
}
};
// Get a reference to the embedded report HTML element
var $reportContainer = $('#reportContainer')[0];
// Embed the report and display it within the div container.
var report = powerbi.embed($reportContainer, embedConfiguration);
</script>