Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
cheesepudding
Regular Visitor

Generating Power Bi Access Token in NodeJS

Hi,

 

I've been trying to generate an access token to call the Power BI REST api.

 

I haven't had any luck following multiple tutorials where I've had various problems:

Can't get VS2015 on my machine (mac) and version 2.21.301221612 of the suggested packaged doesn't ex...

 

I'm trying to get an access token for a web app where the app owns the data, so I already know the credientials.

 

Ideally I would like an access token to stay static so I can generate embed tokens without having to get a new access token for each embed request. I would also like to contain this to NodeJS as that's what my server is written in.

 

Any suggestions?

 

Thanks!

1 ACCEPTED SOLUTION
Eric_Zhang
Microsoft Employee
Microsoft Employee


@cheesepudding wrote:

Hi,

 

I've been trying to generate an access token to call the Power BI REST api.

 

I haven't had any luck following multiple tutorials where I've had various problems:

Can't get VS2015 on my machine (mac) and version 2.21.301221612 of the suggested packaged doesn't ex...

 

I'm trying to get an access token for a web app where the app owns the data, so I already know the credientials.

 

Ideally I would like an access token to stay static so I can generate embed tokens without having to get a new access token for each embed request. I would also like to contain this to NodeJS as that's what my server is written in.

 

Any suggestions?

 

Thanks!


@cheesepudding

It is not possible, by default an access token would expire in one hour, see AAD token lifetime. What is the concern to get a new access token every time? I don't know NodeJS, but you can get a new token simply by calling a POST REST API.

POST /common/oauth2/token HTTP/1.1
Host: login.windows.net 
Content-Type: application/x-www-form-urlencoded

client_id={your client id}&grant_type=password&resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi&username={your power bi account}&password={your power bi account password}

View solution in original post

2 REPLIES 2
Eric_Zhang
Microsoft Employee
Microsoft Employee


@cheesepudding wrote:

Hi,

 

I've been trying to generate an access token to call the Power BI REST api.

 

I haven't had any luck following multiple tutorials where I've had various problems:

Can't get VS2015 on my machine (mac) and version 2.21.301221612 of the suggested packaged doesn't ex...

 

I'm trying to get an access token for a web app where the app owns the data, so I already know the credientials.

 

Ideally I would like an access token to stay static so I can generate embed tokens without having to get a new access token for each embed request. I would also like to contain this to NodeJS as that's what my server is written in.

 

Any suggestions?

 

Thanks!


@cheesepudding

It is not possible, by default an access token would expire in one hour, see AAD token lifetime. What is the concern to get a new access token every time? I don't know NodeJS, but you can get a new token simply by calling a POST REST API.

POST /common/oauth2/token HTTP/1.1
Host: login.windows.net 
Content-Type: application/x-www-form-urlencoded

client_id={your client id}&grant_type=password&resource=https%3A%2F%2Fanalysis.windows.net%2Fpowerbi%2Fapi&username={your power bi account}&password={your power bi account password}

Hi Eric,

 

Thanks for the answer, this is what I was looking for. 

 

Where would I find the documentation for this?

 

I had a look on https://msdn.microsoft.com/library/dn877544.aspx , but their link is broken.

 

Thanks,

Cheese Pudding

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors