Forum Discussion

ed-freeman's avatar
ed-freeman
Advocate II
4 years ago
Solved

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

 

  • 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.

4 Replies