Skip to content

Instantly share code, notes, and snippets.

@krishnaanaril
Created October 5, 2018 09:57
Show Gist options
  • Save krishnaanaril/b766dfd3197635c309d73070352c1f93 to your computer and use it in GitHub Desktop.
Save krishnaanaril/b766dfd3197635c309d73070352c1f93 to your computer and use it in GitHub Desktop.
Method to update Power BI embed token for dashboard.
updateToken() {
// Generate new EmbedToken
this.service.getDashboardEmbedToken()
.subscribe((res) => {
let Token = res.json();
// Get a reference to the embedded report HTML element
var embedDashboard = <HTMLElement>document.getElementById(
'embedDashboard'
);
// Get a reference to the embedded report.
var report = this.powerbi.get(embedDashboard);
// Set AccessToken
report.setAccessToken(Token.token)
.then(()=>{
// Set token expiration listener
// result.expiration is in ISO format
this.setTokenExpirationListener(Token.expiration, 2 /*minutes before expiration*/);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment