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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
GJA
Helper II
Helper II

How to get refreshed token when connecting with PowerBI Desktop to REST API Power BI

Hi, 

 

I need your help to find the exact syntax in order to get a refreshed token to connect to the Power BI Rest API with Power BI desktop.

 

I can get a temporary token using the try function with this link : https://learn.microsoft.com/en-us/rest/api/power-bi/reports/get-reports-in-group

 

But I need to dynamically refresh the token in order use the API with a valid token at each refresh.

 

I tried the code below but it doesn't work (changing the ***** and common with the tenant ID) :

 

GJA_0-1695310064436.png

 

the code : 

() =>
let
body = "grant_type=Password&resource=https://analysis.windows.net/powerbi/api&client_id=****&username=***.onmicrosoft.com&password=*****",
Data=Json.Document(Web.Contents("https://login.microsoftonline.com/common/oauth2/token/", [Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
access_token = Data[access_token]
in
access_token

 

many thanks for those who can help me.

 

Regards, 

 

GJA

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User
2 REPLIES 2
lbendlin
Super User
Super User

Hi, many thanks. It looks OK 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors