Forum Discussion
Power BI REST API - Auto refresh access token
There is a limitation at the moment that any single request to a source that uses OAuth2 authentication will fail after an hour because the access token expires. We're working to address that and refresh the token midway through a request but I can't give you a date for when the fix will be ready. The workaround is to make multiple requests that each take less than an hour; if you were using this code to load data into a table in a semantic model this would involve partitioning the table but I'm not sure there's an easy way of doing the same thing for dataflows.
That said, this is also a great example of why you need to create a custom connector when connecting to web services that use OAuth2 authentication (see https://blog.crossjoin.co.uk/2021/08/29/connecting-to-rest-apis-with-oauth2-authentication-in-power-query-power-bi/). Apart from the one hour limitation you mention there are lots of other cases where token refresh is needed and support for doing that is only available in custom connectors - see https://learn.microsoft.com/en-us/power-query/handling-authentication#implementing-an-oauth-flow
Does the latest gateway version On-premises data gateway April 2024 release | Microsoft Power BI Blog | Microsoft Power BI address this specifically? The release notes are cryptic as always.
- cpwebb2 years agoMicrosoft Employee
I've been told that it does, which is good news!