我正在尝试将PowerBI集成到我的Web应用程序中。这是我使用的代码
window.config = {
instance: 'https://login.microsoftonline.com/',
tenant: 'common', //COMMON OR YOUR TENANT ID
clientId: 'my client IS', //This is your client ID
redirectUri: 'http://localhost:4200/Redirect', //This is your redirect URI
callback: userSignedIn,
popUp: true
};
var ADAL = new AuthenticationContext(config);
function signIn() {
ADAL.login();
}
function userSignedIn(err, token) {
if (!err) {
showWelcomeMessage();
ADAL.acquireToken("https://analysis.windows.net/powerbi/api", function (error, token) {
console.log(error, 't', token);
// Handle ADAL Error
if (error || !token) {
console.log('ADAL Error Occurred: ' + error);
return;
}
function getDataSets(){
var trythis = "Bearer " + token;
var request = new XMLHttpRequest();
request.open('GET', 'https://api.powerbi.com/v1.0/myorg/datasets');
request.setRequestHeader('Authorization', trythis);
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Body:', this.responseText);
}
};
request.send();
}
function showWelcomeMessage() {
var user = ADAL.getCachedUser();
var divWelcome = document.getElementById('WelcomeMessage');
divWelcome.innerHTML = "Welcome " + user.profile.name;
}
登录后,当我尝试获取访问令牌时,出现此错误 “令牌更新操作由于超时而失败”
谁能告诉我如何获取Power BI的访问令牌
答案 0 :(得分:0)
尝试清除浏览器缓存并删除所有cookie,以查看该错误是否消失。另外,在其他浏览器中进行测试以查看是否仍然显示相同的消息。很多时候,此错误仅发生在Internet Explorer中。
有关PowerBi中的访问令牌,请参阅:https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data-get-token