Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Is it possible to update an access token that has expired with a refresh token using the advanced editor/ Power Query M? I ask the following because every time I go in, it asks you to revalidate the credentials and expires. I would like to know if the general idea would work or if I'd run into a dead end. Thanks in advance!
Scenario:
I have an access token from a 3rd party (Caspio) and they have it expire every 24 hours. They give you a refresh token to get a new access token when you'd like to refresh your data.
Can I use an if statement in the advanced editor where I see the general code below (I'm learning Power Query M so I'm kinda pseudo coding):
let
Check = Json.Document(Web.Contents("https://mycaspiodatabase/restapi/", [Headers=[Authorization="bearer myaccesstoken"]])),
Response = Check["Response"],
if Response <> "Active" then myNEWaccesstoken = Json.Document(Web.Contents("https://mycaspiodatabase/restapi/updateToken", [Headers=[Authorization="bearer myrefreshtoken"]])) else Source=Check,
if Response <> "Active" then Source=Json.Document(Web.Contents("https://mycaspiodatabase/restapi/", [Headers=[Authorization="bearer myNEWaccesstoken"]])),
in
Source
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.