Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I have a Power BI dataset which is connected to a sharepoint site. I want to be able to do the following with a AAD Service Account:
I able to perform 1 and 2 using rest api but receive an error when attempting to update credentials for a SharePoint site datasource.
Below is a snippet of the Python code I am using, using this guide as a reference https://learn.microsoft.com/en-us/rest/api/power-bi/gateways/update-datasource
...
access_token = asdhaudhuaihfa...
credentials = {"credentialData": {"name": "accessToken", "value": access_token}}
credentialType = "OAuth2"
def update_credentials(gateway_id, datasource_id, credentialType,
credentials, privacyLevel=None, useCallerAADIdentity = None,
useEndUserOAuth2Credentials = None):
# PATCH https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId}
body = {
"credentialDetails": {
"credentialType": credentialType,
"credentials": json.dumps(credentials),
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "None",
"privacyLevel": privacyLevel,
'useCallerAADIdentity': useCallerAADIdentity,
'useEndUserOAuth2Credentials': useEndUserOAuth2Credentials
}
}
url =
f'https://api.powerbi.com/v1.0/myorg/gateways/{gateway_id}/datasources/{datasource_id}'
print(f"Rest API: {url}")
api_call = requests.patch(url, data = json.dumps(body),
headers= {"Authorization": f"Bearer {access_token}", "Content-Type": "application/json"})
return api_call
I have tried using the PBI access token, a SharePoint Site access token, trying different (True/False/Blank) combinations of useCallerAADIdentity & useEndUserOAuth2Credentials. All have returned error codes.
Error codes:
DM_GWPipeline_Gateway_DataSourceAccessError
Specifying UseCallerOAuthIdentity requires credential type to be OAuth2
Any help would be greatly appreciated.
My App API permissions:
Lorcan
Hello,
Were you able to solve the problem?
I have a similar problem: Re: Power BI dataset refresh: use service principa... - Microsoft Fabric Community and I managed to get it working with the SharePoint resource and permissions but this needs to work with a client certificate. You need to upload a certificate and create a JWT header + payload. With this you can create an access token that gives you access to your SharePointList with Power BI.
https://learn.microsoft.com/en-us/entra/identity-platform/certificate-credentials
https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow
I would like to use MS Graph and a client secret instead but haven't found the solution yet...
You also need to remove useEndUserOAuth2Credentials from your body because this is only used when using DirectQuery like Azure SQL or Kusto. It will give you an error that this parameter is only for those data sources.
Kind regards
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |