Forum Discussion
Trino Custom Connector Using OAuth2 on Gateway
- 11 months ago
Hi CmdGouda ,
Thanks for posting in Microsoft Fabric Community and sharing the details of your scenario.
Based on the code you’ve added for token and refresh token handling, the behavior you’re describing is consistent with a known limitation in Power BI service refresh when using OAuth2.
According to Microsoft documentation, the Microsoft Entra ID OAuth token expires in about one hour. If your dataset refresh takes longer than that, the token can expire before the process completes, which results in a credentials error. The service can wait for up to two hours while loading data, so if the token is not renewed mid-process, refresh can fail. Microsoft is investigating a solution for this, but currently token refresh during long-running operations is not supported.
Troubleshoot refresh scenarios - Power BI | Microsoft LearnSimilar thread: Refresh not working for OAuth based Custom Connect... - Microsoft Fabric Community
There have also been similar discussions where users found the issue was caused by multiple refresh requests running in parallel against the same custom connector. When the refresh token was exchanged by the first request, subsequent requests tried to reuse it and failed because it was already consumed. Some of the approaches mentioned include adjusting refresh token usage settings or adding a grace period for token reuse to avoid the race condition.
Re: Custom Data Connector OAuth2 refresh token not... - Microsoft Fabric CommunityAlso, please make sure that the Test Connection logic in your custom connector is set up correctly, since this is required for scheduled refresh in the service to succeed. Microsoft has guidance on how to implement it here:
Use custom data connectors with the on-premises data gateway - Power BI | Microsoft LearnIn this discussion, changes to the refresh token handling using grant_type=refresh_token fixed the scheduled refresh: Custom Connector OAuth2 Scheduled Refresh Issue - Microsoft Fabric Community
Hope this helps. Please reach out for further assistance.
Thank you.
Hi CmdGouda ,
Thanks for posting in Microsoft Fabric Community and sharing the details of your scenario.
Based on the code you’ve added for token and refresh token handling, the behavior you’re describing is consistent with a known limitation in Power BI service refresh when using OAuth2.
According to Microsoft documentation, the Microsoft Entra ID OAuth token expires in about one hour. If your dataset refresh takes longer than that, the token can expire before the process completes, which results in a credentials error. The service can wait for up to two hours while loading data, so if the token is not renewed mid-process, refresh can fail. Microsoft is investigating a solution for this, but currently token refresh during long-running operations is not supported.
Troubleshoot refresh scenarios - Power BI | Microsoft Learn
Similar thread: Refresh not working for OAuth based Custom Connect... - Microsoft Fabric Community
There have also been similar discussions where users found the issue was caused by multiple refresh requests running in parallel against the same custom connector. When the refresh token was exchanged by the first request, subsequent requests tried to reuse it and failed because it was already consumed. Some of the approaches mentioned include adjusting refresh token usage settings or adding a grace period for token reuse to avoid the race condition.
Re: Custom Data Connector OAuth2 refresh token not... - Microsoft Fabric Community
Also, please make sure that the Test Connection logic in your custom connector is set up correctly, since this is required for scheduled refresh in the service to succeed. Microsoft has guidance on how to implement it here:
Use custom data connectors with the on-premises data gateway - Power BI | Microsoft Learn
In this discussion, changes to the refresh token handling using grant_type=refresh_token fixed the scheduled refresh: Custom Connector OAuth2 Scheduled Refresh Issue - Microsoft Fabric Community
Hope this helps. Please reach out for further assistance.
Thank you.
Hi CmdGouda ,
Just wanted to check if the response provided was helpful. If further assistance is needed, please reach out.
Thank you.