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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JakeSky
New Member

Rest Api has 15 min time out and i need to generate a new Auth token with pagination of 50 rows per

 
So im dealing with an Rest Api that has a 900 second expiration. 


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

3 REPLIES 3
JakeSky
New Member

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. 

ams1
Responsive Resident
Responsive Resident

@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.

ams1
Responsive Resident
Responsive Resident

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?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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 Kudoed Authors