I am using Powershell to update credentials on a Power BI datasource based on Sql Azure.
The credentials are that of a Service Principal's, I obtain a Sql access token and submit changes.
The payload lokos like this:
$UpdateUserCredential = @{
credentialDetails = @{
credentialType = "OAuth2"
credentials = "{`"credentialData`":[{`"name`":`"accessToken`", `"value`":`"$token`"}]}"
encryptedConnection = "Encrypted"
encryptionAlgorithm = "None"
privacyLevel = "None"
}
} | ConvertTo-Json
The datasource is set to refresh every 10 days. Do I need to update the credentials programmatically when it expires each time - how often does the credential expire?
Is there a better way to retain credentials within Power BI for a datasource connection that can survive future scheduled refreshes without having to re-enter credentials? e.g using basic username password authentication perhaps, as opposed to OAuth?