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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ed-freeman
Advocate II
Advocate II

Updating OAuth data source credentials via API - bearer token expires, invalidating connection

We are connecting to our data source using OAuth credentials. Sometimes, Power BI requires us to re-enter our credentials in the Service, when the token has been invalidated for some reason (e.g. change of dataset ownership).

We then update the OAuth credentials via the Gateways - Update Datasource API. We provide a valid Bearer Token as per the OAuth update example and everything initially works as expected. 

However, obviously the bearer token expires after an hour (the default for most bearer tokens), and the Power BI Service asks us to re-enter our credentials. We then have to run this code every hour (or at least before any refresh) to make sure the credentials don't expire.

This doesn't happen if you update the credentials through the UI - refreshing of the token must be being handled by the Power BI Service behind the scenes. But there is no option to provide a "refresh token" in the above "Update Datasource" API.

So how is this meant to be handled? Or is this a limitation in the API?

Thanks, Ed

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

That's a limitation in the API. I seem to recall that they were planning to address that. Not sure if it is in the works - make sure to vote for the idea/post a new one.

View solution in original post

4 REPLIES 4
V-lianl-msft
Community Support
Community Support

Hi @ed-freeman ,

 

Hope this thread can help you:

https://community.powerbi.com/t5/Power-Query/Refresh-token-api-call/td-p/937553 

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Liang,

Thanks for the response. Unfortunately the link you've shared isn't quite the same thing and the solution isn't really viable. We're authenticating to Azure Synapse using the native connector which has built-in OAuth support. Updating credentials manually supports the refresh token scenario. It's just there's a limitation when trying to do the same thing via the API.

Thank you,

Ed

lbendlin
Super User
Super User

That's a limitation in the API. I seem to recall that they were planning to address that. Not sure if it is in the works - make sure to vote for the idea/post a new one.

Hey @lbendlin,

Thanks for your response. I thought as much, though it's news to me that the team was planning to address it. If so, that's welcome news!

In any case, I've submitted an idea: Add support for supplying refresh token for OAuth source in Gateways - Update Datasource API.

Ed

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.