我尝试使用ADAL.js对PowerBI进行身份验证以获取access_token和embed_token,以便在仅限html / javascript的#34; webpart&#34中嵌入PowerBI报告/信息中心/磁贴;。我的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中找到任何访问令牌等。我显然错过了一些东西,但是...... :)任何帮助都会非常适合
答案 0 :(得分:1)
看: 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;
}
}