本文介绍了如何使用ADAL.JS获取PowerBI访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试使用ADAL.js对PowerBI进行身份验证,以获取将PowerBI报告/仪表板/图块嵌入到仅html / javascript的 webpart中所需的access_token和embed_token。我的adal配置看起来像:I'm trying to use ADAL.js to authenticate against PowerBI in order to get an access_token and the embed_token needed to embed PowerBI reports/dashboards/tiles in a html/javascript-only "webpart". My adal-config looks like: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中找不到任何访问令牌等。我显然丢失了一些东西,但是..::)任何帮助都将得到广泛应用But I can't seem to find any access-token etc in the user.profile I get. I am obviously missing something but what.. :) Any help would be much appriciated推荐答案查看: https://community.powerbi.com/t5 / Developer / get-Access-token-using-js / mp / 350294 以及以下内容: https://community.powerbi.com/t5/Developer/How-to-Generate- Embed-Token-in-pure-JavaScript / td-p / 350056您可以使用ADAL.js本身获取访问令牌you can use ADAL.js to get the access token itselfwindow.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; }} 这篇关于如何使用ADAL.JS获取PowerBI访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!