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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I have tried creating a function that could be called on once DateTime.LocalNow() > Expiration ( which is DateTime.LocalNow()+duration(0,0,0,900) upon receiving the first Auth token) that would push a new Auth token into a loop (because the data is paginated with a low limit of rows per a pull ... its 50). im needing to pull the entire data set which takes more then the 15 min time window the rest api allows. Any suggestions or ideas would be very helpful =D
The Error i get after 900 seconds is We couldn't authenticate with the credentials provided. Please try again
The current Fx im using to attempt to get the new Auth token is
(Authcode as text) =>
let
body2 = "*****",
Data=Json.Document(Web.Contents("https://xxxxxxx", [RelativePath= "xxxxxxxx" ,Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body2)])),
FormatAsJson = Json.Document(Data),
access_token1 =Data[access_token],
access_tokenHeader= "Bearer "& access_token1
in if Authcode = access_tokenHeader then getNewAuth(Authcode) else access_tokenHeader
The code leading up to this looks like this
Source2 = if getTime() > Endtime then getNewAuth(Authcode)
else Authcode,
That line of code is withen another fx loop due to pagination
That would be the idea. i had even set the expiration at 750 seconds instead of 900 but it still doesnt seem to be working.
@JakeSkythanks.
It would be very helpful if we get more code - otherwise, for testing with a dummy webserver I'll have to create code which you'll have to adapt to your own.
If you are able to paste the code here (at least the functions name, parameters) - after removing confidential info from it - I'll be able to use it for testing, if not, it might take longer.
Hi @JakeSky
So basically you would like PowerQuery to automatically call that function say a few (tens of) seconds before expiration so that you don't get "We couldn't authenticate with the credentials provided", right?
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.