Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi guys,
I try to use a Rest API that uses an access token as authentication, which expires in 10 minutes. When this access token is expired, I need to get a new access token using a refresh token, that can be used once and is valid for 30 days. Each time you request a new access token, a new refresh token is returned aswell that must be used in the next refresh. Therefore, the refresh token needs to be stored somewhere, where it can both be (1) updated in the current refresh run and (2) collected to refresh the access token in the next refresh run. This is were we run into the problem as we do not know how to setup a framework in Power BI that facilitates both these options.
Each time we request a new access token, the response is as follows:
{
"access_token": "xxxxxxx",
"token_type": "bearer",
"expires_in": "600",
"refresh_token": "yyyyyy"
}
Storing both tokens in a table, seems to be the logical option here, but there is an additonal catch; it can occur that the refresh of the data takes more than 10 minutes. In which case the access_token needs to be refreshed multiple times during the same Power BI refresh run. And since the refresh_token also changes after refreshing the access_token, it cannot be stored in a parameter.
The issue is almost similar to the following issue: Power-Query/Channel-Advisor-API-Connection-with-auth-key-creation
However our refresh_token (authentication) is not static (like a username and password), but changes after each refresh.
Is there any way to define a variable for the refresh_token that can be used in each different query and that can also be updated whenever you request a new access_token (even during the same refresh run)?
Solved! Go to Solution.
Power BI has no memory and no concept of (mutable) variables. You need to treat each API call as if it were the first.
Hi @MichaelvdZ, instead of trying to refresh my access token, I found a really easy way to have Power BI request a new access token after my original one expired. I hope this helps!
See my post in this thread: https://community.fabric.microsoft.com/t5/Service/API-with-dynamic-access-token-can-t-refresh-in-Pow...
☝️ this is simply awesome
@peggysue can't thank you enough. The method works , I wasted a whole week on "AI" to find out how to refresh token as my jobs were running for an hour and getting errored out due to expired token.
You saved me from eventually being frustrated on this.
I have run several test jobs following this 1hr+, 2hr+ and it never errored out on an expired token.
Power BI has no memory and no concept of (mutable) variables. You need to treat each API call as if it were the first.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
25 | |
12 | |
11 | |
11 | |
8 |
User | Count |
---|---|
45 | |
28 | |
14 | |
14 | |
13 |