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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
cb12
New Member

REST API 403 Forbidden after 1 hour

Hi,

 

I have written a fairly simple .NET application to POST rows continually to a dataset. This works absolutely fine and I couldn't be happier with the performance of the API either. However, I have an annoying issue where after 60 minutes I start to continually get 403 forbidden responses to my requests. This must be due to my access token expiring, but 1 hour seems like an awfully short period of time for this to start happening. Is this expected behaviour? I've seen other people mentioning needing to retrieve a new token every few days, but no one suggesting they have to do so every hour!

 

Thanks

 

CB

1 ACCEPTED SOLUTION
Eric_Zhang
Microsoft Employee
Microsoft Employee

@cb12

The token expiration is an AAD behavior and 60 minutes seems by default. Check Configurable Token Lifetimes in Azure Active Directory. For further question on AAD, you'd get better response from the dedicated forum.

 

By the way, how did you call the REST API to push data? Can you send the request with a new generated token always?

View solution in original post

2 REPLIES 2
Eric_Zhang
Microsoft Employee
Microsoft Employee

@cb12

The token expiration is an AAD behavior and 60 minutes seems by default. Check Configurable Token Lifetimes in Azure Active Directory. For further question on AAD, you'd get better response from the dedicated forum.

 

By the way, how did you call the REST API to push data? Can you send the request with a new generated token always?

ah, yes. thank you! So simple.

 

To answer your question, my application starts up and calls a method to get the token once at the start and then passes that into each subsequent request. I could change this to generate a token each time, but I'm trying post data ~once every 2 seconds and that seems like a lot of unnecessary overhead. Also, this is just a dev solution at the moment ad so the account I'm using has MFA enabled. We could extend the lifetime default to a day, but either way just rewrite the code to catch the forbidden exception and generate a new token. Thanks for your help 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.