<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic API - Service Principle Secret Generation in Administration &amp; Architecture</title>
    <link>https://community.databricks.com/t5/administration-architecture/api-service-principle-secret-generation/m-p/158233#M5297</link>
    <description>&lt;P class=""&gt;&lt;SPAN&gt;Hi everyone,&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;I am looking for a way to automatically create service principals, including their secrets, for M2M OAuth.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;I know that service principals can be created via the API, but it seems that creating secrets for those service principals via the API is currently not supported.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Does anyone have an idea or workaround for this? Alternatively, do you know whether the Databricks engineers are already working on supporting this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;I know that OBO-tokens are an option, but security wise not a great choise.&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Thank you in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kind regards&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jun 2026 17:05:23 GMT</pubDate>
    <dc:creator>yustus</dc:creator>
    <dc:date>2026-06-03T17:05:23Z</dc:date>
    <item>
      <title>API - Service Principle Secret Generation</title>
      <link>https://community.databricks.com/t5/administration-architecture/api-service-principle-secret-generation/m-p/158233#M5297</link>
      <description>&lt;P class=""&gt;&lt;SPAN&gt;Hi everyone,&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;I am looking for a way to automatically create service principals, including their secrets, for M2M OAuth.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;I know that service principals can be created via the API, but it seems that creating secrets for those service principals via the API is currently not supported.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Does anyone have an idea or workaround for this? Alternatively, do you know whether the Databricks engineers are already working on supporting this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;I know that OBO-tokens are an option, but security wise not a great choise.&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Thank you in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kind regards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2026 17:05:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/api-service-principle-secret-generation/m-p/158233#M5297</guid>
      <dc:creator>yustus</dc:creator>
      <dc:date>2026-06-03T17:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: API - Service Principle Secret Generation</title>
      <link>https://community.databricks.com/t5/administration-architecture/api-service-principle-secret-generation/m-p/158238#M5298</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/134020"&gt;@yustus&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The&amp;nbsp;AccountClient in the Databricks Python SDK exposes service_principal_secrets, which lets administrators create and manage OAuth secrets for service principals. The generated secrets can then be used to obtain OAuth access tokens for accessing both Databricks Account and Workspace APIs.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from databricks.sdk import AccountClient

a = AccountClient(
    host="https://accounts.azuredatabricks.net",
    account_id="&amp;lt;your-account-id&amp;gt;",
    client_id="&amp;lt;admin-sp-client-id&amp;gt;",
    client_secret="&amp;lt;admin-sp-secret&amp;gt;"
)

# Create SP
sp = a.service_principals.create(display_name="my-automation-sp")

# Create OAuth secret for it
secret = a.service_principal_secrets.create(service_principal_id=str(sp.id))

print(f"Client ID: {sp.application_id}")
print(f"Secret: {secret.secret}")  # Store this securely — shown only once!&lt;/LI-CODE&gt;&lt;P&gt;You can also use terraform:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;resource "databricks_service_principal" "sp" {
  provider     = databricks.account
  display_name = "my-automation-sp"
}

resource "databricks_service_principal_secret" "sp_secret" {
  service_principal_id = databricks_service_principal.sp.id
  lifetime             = "15552000s" # 180 days
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;If my answer was helpful, please consider marking it as accepted solution.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2026 19:28:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/api-service-principle-secret-generation/m-p/158238#M5298</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2026-06-03T19:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: API - Service Principle Secret Generation</title>
      <link>https://community.databricks.com/t5/administration-architecture/api-service-principle-secret-generation/m-p/158261#M5299</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/134020"&gt;@yustus&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It’s great that you are prioritizing secure M2M OAuth over OBO tokens!&lt;/P&gt;&lt;P&gt;while &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/110502"&gt;@szymon_dybczak&lt;/a&gt;&amp;nbsp;already mentioned the Python SDK and Terraform, I wanted to offer a few alternative approaches depending on how your automation is&amp;nbsp;set up:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;1. The Direct REST API (It &lt;I&gt;is&lt;/I&gt; actually supported!)&lt;/STRONG&gt; You mentioned that creating secrets via the API seems unsupported. The good news is that it actually is supported via the &lt;STRONG&gt;Account API&lt;/STRONG&gt; (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 : &lt;A href="https://docs.databricks.com/api/azure/account/accountserviceprincipals/create" target="_blank" rel="noopener"&gt;https://docs.databricks.com/api/azure/account/accountserviceprincipals/create&lt;/A&gt;)&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;# Using standard cURL to the Account API&lt;/SPAN&gt;
curl -X POST -H &lt;SPAN class=""&gt;"Authorization: Bearer &amp;lt;your-admin-token&amp;gt;"&lt;/SPAN&gt; \
https://accounts.azuredatabricks.net/api/2.0/accounts/&amp;lt;your-account-id&amp;gt;/servicePrincipals/&amp;lt;sp-id&amp;gt;/credentials/secrets&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;I&gt;(Note: Be sure to replace the Azure URL with the AWS/GCP equivalent if you are on a different cloud).&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;2. The Databricks CLI (Best for simple bash/shell automation)&lt;/STRONG&gt; 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.&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;(Reference: &lt;A href="https://docs.databricks.com/aws/en/dev-tools/cli/reference/service-principals-commands" target="_blank" rel="noopener"&gt;https://docs.databricks.com/aws/en/dev-tools/cli/reference/service-principals-commands&lt;/A&gt;)&lt;BR /&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;# Generate the secret directly via CLI&lt;/SPAN&gt;
databricks service-principal-secrets create &amp;lt;service_principal_id&amp;gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;3. Cloud-Native Identities (Zero Databricks Secrets)&lt;/STRONG&gt; If you are using Azure, AWS, or GCP, the most secure workaround is to &lt;STRONG&gt;not generate Databricks secrets at all&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;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 &lt;STRONG&gt;Azure AD Service Principal&lt;/STRONG&gt; or a &lt;STRONG&gt;Managed Identity&lt;/STRONG&gt;. You authenticate to Azure AD to get an Entra ID token, and Databricks will natively accept that token for M2M API calls.&lt;/P&gt;&lt;P&gt;This is often considered the gold standard for security because:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;You don't have to generate, rotate, or store Databricks secrets.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Everything is managed centrally via your cloud provider's IAM.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Hope this gives you a few extra angles to tackle your automation!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jun 2026 23:33:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/api-service-principle-secret-generation/m-p/158261#M5299</guid>
      <dc:creator>ShamenParis</dc:creator>
      <dc:date>2026-06-03T23:33:01Z</dc:date>
    </item>
  </channel>
</rss>

