I'm attempting to call the Databricks API using the method described in Get an Azure Active Directory token using a service principal.
However when I use the management endpoint access token to access the Databricks REST API, I get HTTP ERROR 403. User Not Authorized.
The first 2 calls successfully return w/the appropriate access tokens. These are passed into the Databricks REST API per the documentation, however it returns 403. Help please.
# Attempting this
# * https://learn.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/aad/service-prin-aad-token
tenantId="secret"
subscriptionId="secret"
resourceGroupId="my-test-group"
clientId="secret"
clientSecret="verysecret"
dbResourceId="2ff814a6-3304-4ab8-85cb-cd0e6f879c1d"
dbWorkspaceName="my-test-db"
az login -u $1 -o table
dbAccessToken=$(curl -X GET \
-H 'Content-Type: application/x-www-form-urlencoded' -d \
'grant_type=client_credentials&client_id='${clientId}'&resource='${dbResourceId}'&client_secret='${clientSecret} \
https://login.microsoftonline.com/${tenantId}/oauth2/token | jq -r '.access_token')
echo Access Token
echo $dbAccessToken
mgtAccessToken=$(curl -X GET \
-H 'Content-Type: application/x-www-form-urlencoded' -d \
'grant_type=client_credentials&client_id='${clientId}'&resource=https://management.core.windows.net/&client_secret='${clientSecret} \
https://login.microsoftonline.com/${tenantId}/oauth2/token | jq -r '.access_token')
echo
echo Management Access Token
echo $mgtAccessToken
echo
result=$(curl -X GET \
-H 'Authorization: Bearer '${dbAccessToken} \
-H 'X-Databricks-Azure-SP-Management-Token: '${mgtAccessToken} \
-H 'X-Databricks-Azure-Workspace-Resource-Id: /subscriptions/'${subscriptionId}'/resourceGroups/'${resourceGroupId}'/providers/Microsoft.Databricks/workspaces/'${dbWorkspaceName} \
https://"secretworkspaceid".azuredatabricks.net/api/2.0/clusters/list)
echo
echo $result