我正在尝试使用ADAL.js对PowerBI进行身份验证,以便获得在html/javascript-only "webpart“中嵌入PowerBI报告/仪表板/磁贴所需的access_token和embed_token。我的adal-config如下所示:
config = {
instance: 'https://login.windows.net/common/oauth2/authorize/',
tenant: 'tenant.onmicrosoft.com',
clientId: '05xxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxx',
loginResource: "https://analysis.windows.net/powerbi/api",
postLogoutRedirectUri: window.location.origin,
cacheLocation: 'localStorage',
};但是在我得到的user.profile中,我似乎找不到任何访问令牌等。我显然漏掉了什么.:)任何帮助都是非常有用的
发布于 2018-03-25 17:27:49
看看:https://community.powerbi.com/t5/Developer/get-Access-token-using-js/m-p/350294,还有这个:https://community.powerbi.com/t5/Developer/How-to-Generate-Embed-Token-in-pure-JavaScript/td-p/350056
您可以使用ADAL.js获取访问令牌本身
window.config = {
instance: 'https://login.microsoftonline.com/',
tenant: 'common', //COMMON OR YOUR TENANT ID
clientId: 'XXXXX', //This is your client ID
redirectUri: 'XXXXXX', //This is your redirect URI
callback: userSignedIn,
popUp: true
};
var ADAL = new AuthenticationContext(config);
function signIn() {
ADAL.login();
}
function userSignedIn(err, token) {
console.log('userSignedIn called');
if (!err) {
showWelcomeMessage();
ADAL.acquireToken("https://analysis.windows.net/powerbi/api", function (error, token) {
// Handle ADAL Error
if (error || !token) {
printErrorMessage('ADAL Error Occurred: ' + error);
return;
}
}
https://stackoverflow.com/questions/48523851
复制相似问题