Created
October 5, 2018 09:57
-
-
Save krishnaanaril/b766dfd3197635c309d73070352c1f93 to your computer and use it in GitHub Desktop.
Method to update Power BI embed token for dashboard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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