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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Employee
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
Employee
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
March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.