cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
demo
New Member

create app based service principal auth token using nodejs

I'm trying to create app based service principal authentication token using Node JS. I'm able to get token(not sure it's service principal token) able to pass in header as Auth bearer token able to get Embed URL While running embed URL getting Sign in page, what is the issue ? I'm using below code :

/*authentication.js */ 
async function getAuthenticationToken() { 
var adal = require('adal-node'); 
var AuthenticationContext = adal.AuthenticationContext; 
var context = new AuthenticationContext(authorityUrl); context.acquireTokenWithClientCredentials(config.resourceUrl,config.appId,config.clientSecret, function(err, tokenResponse){
 if (err) reject(" ~ "+err);
 resolve(tokenResponse); 
}) 
}
 /* index.js */ 
var auth = require(__dirname +'/authentication.js'); 
tokenResponse = await auth.getAuthenticationToken(); 
var token = tokenResponse.accessToken; 
var resd = await utils.sendGetReportRequestAsync(requestParams.url, requestParams.options); 
var embed = resd.embedUrl+"&autoAuth=true";
1 REPLY 1
v-xicai
Community Support
Community Support

Hi @demo ,

 

You may refer to the link: https://powerbi.microsoft.com/en-us/blog/pbie-nodejs-sdk/.

 

If you still have this issue for Power BI, you'd better create a support ticket in Power BI Support to get further help.

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors