title: Databricks API 2.0- Create Secret Scope - TEMPORARILY_UNAVAILABLE
body: <p>I am automating the deployment of an infrastructure containing an Azure Databricks instance. To be able to use the Azure Blob Storage from within Databricks I want to create a Secret Scope via the Databricks REST API 2.0 in my DevOps Pipeline running a Python job.</p>
  <p>When I try to create the secret scope, I get the response</p>
  <blockquote>
  <p>{&quot;message&quot;:&quot;Authentication is temporarily unavailable. Please try again later.&quot;, &quot;error_code&quot;: &quot;TEMPORARILY_UNAVAILABLE&quot;}</p>
  </blockquote>
  <p>I was already able to create a databricks access token using the API, i.e. the endpoint /token/create worked perfectly.</p>
  <p>I am authenticating to databricks using the Code from the answer to this question: <a href="https://stackoverflow.com/a/61826488/2196531">https://stackoverflow.com/a/61826488/2196531</a><br />
  This is how I am able to create a token and how I try to generate the scope:</p>
  <pre><code>import requests
  import adal
  import json
  
  # set variables 
  clientId = &quot;&lt;Service Principal Id&gt;&quot;
  tenantId = &quot;&lt;Tenant Id&gt;&quot;
  clientSecret = &quot;&lt;Service Principal Secret&gt;&quot;
  subscription_id = &quot;&lt;Subscription Id&gt;&quot;
  resource_group = &quot;&lt;Resource Group Name&gt;&quot;
  databricks_workspace = &quot;&lt;Databricks Workspace Name&gt;&quot;
  dbricks_url = &quot;&lt;Databricks Azure URL&gt;&quot;
  
  # Acquire a token to authenticate against Azure management API
  authority_url = 'https://login.microsoftonline.com/'+tenantId
  context = adal.AuthenticationContext(authority_url)
  token = context.acquire_token_with_client_credentials(
      resource='https://management.core.windows.net/',
      client_id=clientId,
      client_secret=clientSecret
  )
  azToken = token.get('accessToken')
  
  # Acquire a token to authenticate against the Azure Databricks Resource
  token = context.acquire_token_with_client_credentials(
      resource=&quot;2ff814a6-3304-4ab8-85cb-cd0e6f879c1d&quot;,
      client_id=clientId,
      client_secret=clientSecret
  )
  adbToken = token.get('accessToken')
  
  # Format Request API Url
  dbricks_api = &quot;https://{}/api/2.0&quot;.format(dbricks_url)
  
  # Request Authentication
  dbricks_auth = {
      &quot;Authorization&quot;: &quot;Bearer {}&quot;.format(adbToken),
      &quot;X-Databricks-Azure-SP-Management-Token&quot;: azToken,
      &quot;X-Databricks-Azure-Workspace-Resource-Id&quot;: (&quot;/subscriptions/{}/resourceGroups/{}/providers/Microsoft.Databricks/workspaces/{}&quot;.format(subscription_id, resource_group, databricks_workspace) )
      }
  
  # Creating a databricks token
  payload = {
      &quot;comment&quot;: &quot;This token is created by API call&quot;
  }
  requests.post(f&quot;{dbricks_api}/token/create&quot;, headers=dbricks_auth, json=payload)
  # works
  
  # Creating a databricks secret scope
  payload = {
      &quot;scope&quot;: &quot;my-databricks-secret-scope&quot;,
      &quot;initial_manage_principal&quot;: &quot;users&quot;
  }
  requests.post(f&quot;{dbricks_api}/secrets/scopes/create&quot;, headers=dbricks_auth, json=payload)
  # returns {&quot;message&quot;:&quot;Authentication is temporarily unavailable. Please try again later.&quot;, &quot;error_code&quot;: &quot;TEMPORARILY_UNAVAILABLE&quot;}
  </code></pre>
  <p>Databricks is running in westeurope.<br />
  Python 3.8.5 x64<br />
  Packages used in the Code snippet</p>
  <ul>
  <li>adal-1.2.4</li>
  <li>requests-2.24.0</li>
  </ul>
  <p>Is there a problem with the databricks API or am I doing something wrong?</p>