Forum Discussion
Updating credentials for a cloud data source as a service principal
I'm trying to update credentials for a cloud data source that uses OAuth2 as a service principal. The purpose is to be able to refresh the dataset. We would prefer not to use an on-premises gateway for our use case.
There is an Updata Datasource method that updates the credentials for gateway datasources, but it does not appear to work for cloud datasources. Based on this post, I was actually able to find a gateway ID and data source ID for a cloud data source, but updata datasource always returned status 400 DM_GWPipeline_Gateway_DataSourceAccessError for it.
Is there actually a way to update credentials for a cloud data source as a service principal? Or is this an inherent limitation; I saw that this says "Cloud data sources and their corresponding credentials are managed at the user level."
6 Replies
- lbendlinSuper User
You need to send the new token in the payload of the call.
Gateways - Update Datasource - REST API (Power BI Power BI REST APIs) | Microsoft Docs
- Andrew-T2Frequent Visitor
Has anyone resolved this? I too find that cloud datasources credential updates don't seem to work (400 DM_GWPipeline_Gateway_DataSourceAccessError), and are mostly forgotten in the on-prem gateway oreinted documentation.
Trying to add a cloud datasource to the on-prem gateway doesn't help either.
Get Datasource Status didn't work for me either.- xli629bHelper II
We were eventually able to get this to work by calling Update Datasource with the cloud datasource gateway ID returned by Get Datasources. However, the following conditions also had to be true:
1) Used plain credentials, not encrypted ones:{ credentialDetails: { credentialType: "OAuth2", credentials: "{\"credentialData\":[{\"name\":\"accessToken\",\"value\":\"eyJh[...]\"}]}", encryptedConnection: "Encrypted", encryptionAlgorithm: "None", privacyLevel: "None", useEndUserOAuth2Credentials: "False" } }
2) Used a service principal profile to upload the report/dataset and for all operations.