Hi @yustus
Itโs great that you are prioritizing secure M2M OAuth over OBO tokens!
while @szymon_dybczak already mentioned the Python SDK and Terraform, I wanted to offer a few alternative approaches depending on how your automation is set up:
1. The Direct REST API (It is actually supported!) You mentioned that creating secrets via the API seems unsupported. The good news is that it actually is supported via the Account API (not the Workspace API). You can achieve this using a simple standard HTTP POST request. This is great if you don't want to rely on SDKs or Terraform. (Reference : https://docs.databricks.com/api/azure/account/accountserviceprincipals/create)
# Using standard cURL to the Account API
curl -X POST -H "Authorization: Bearer <your-admin-token>" \
https://accounts.azuredatabricks.net/api/2.0/accounts/<your-account-id>/servicePrincipals/<sp-id>/credentials/secrets
(Note: Be sure to replace the Azure URL with the AWS/GCP equivalent if you are on a different cloud).
2. The Databricks CLI (Best for simple bash/shell automation) If you are writing shell scripts for CI/CD, the new Databricks CLI natively supports secret generation and is much lighter than setting up a Python environment.
# Generate the secret directly via CLI
databricks service-principal-secrets create <service_principal_id>
3. Cloud-Native Identities (Zero Databricks Secrets) If you are using Azure, AWS, or GCP, the most secure workaround is to not generate Databricks secrets at all.
Instead of creating a Databricks-native OAuth secret, you can federate authentication to your cloud provider. For example, if you are on Azure, you can use an Azure AD Service Principal or a Managed Identity. You authenticate to Azure AD to get an Entra ID token, and Databricks will natively accept that token for M2M API calls.
This is often considered the gold standard for security because:
You don't have to generate, rotate, or store Databricks secrets.
Everything is managed centrally via your cloud provider's IAM.
Hope this gives you a few extra angles to tackle your automation!