<?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 Authenticating to Accounts Console Using Client ID and Secret via Terraform and Databricks CLI in Data Governance</title>
    <link>https://community.databricks.com/t5/data-governance/authenticating-to-accounts-console-using-client-id-and-secret/m-p/72338#M1862</link>
    <description>&lt;P&gt;I am currently working on a project where I need to authenticate to the Databricks accounts console from Terraform using a client ID and client secret. Here is the relevant portion of my Terraform configuration:&lt;BR /&gt;&lt;BR /&gt;// Provider for Databricks account&lt;BR /&gt;provider "databricks" {&lt;BR /&gt;alias = "azure_account"&lt;BR /&gt;host = "&lt;A href="https://accounts.azuredatabricks.net" target="_blank"&gt;https://accounts.azuredatabricks.net&lt;/A&gt;"&lt;BR /&gt;account_id = var.account_id&lt;BR /&gt;azure_client_id = var.client_id&lt;BR /&gt;azure_client_secret = var.client_secret&lt;BR /&gt;}&lt;BR /&gt;I execute all the Terraform tasks from a shell script. Within this script, we use a Databricks CLI command to check whether the workspace is assigned to a metastore:&lt;BR /&gt;&lt;BR /&gt;sh&lt;BR /&gt;databricks auth login --host &lt;A href="https://accounts.azuredatabricks.net" target="_blank"&gt;https://accounts.azuredatabricks.net&lt;/A&gt; --account-id "$account_id"&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;assignment&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;$(&lt;/SPAN&gt;&lt;SPAN&gt;databricks&lt;/SPAN&gt;&lt;SPAN&gt; account metastore-assignments get "&lt;/SPAN&gt;&lt;SPAN&gt;$workspace_id&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN&gt;2&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/dev/null)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;However, I am unable to authenticate since the command attempts to authenticate using a client ID and client secret.&lt;/P&gt;&lt;P&gt;Is there a way to authenticate using the client ID and client secret directly with the Databricks CLI? If not, can you suggest any alternative methods to achieve this authentication?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jv_v_0-1718116490905.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/8214i74159B4BB3368A6D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="jv_v_0-1718116490905.png" alt="jv_v_0-1718116490905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jun 2024 14:35:19 GMT</pubDate>
    <dc:creator>jv_v</dc:creator>
    <dc:date>2024-06-11T14:35:19Z</dc:date>
    <item>
      <title>Authenticating to Accounts Console Using Client ID and Secret via Terraform and Databricks CLI</title>
      <link>https://community.databricks.com/t5/data-governance/authenticating-to-accounts-console-using-client-id-and-secret/m-p/72338#M1862</link>
      <description>&lt;P&gt;I am currently working on a project where I need to authenticate to the Databricks accounts console from Terraform using a client ID and client secret. Here is the relevant portion of my Terraform configuration:&lt;BR /&gt;&lt;BR /&gt;// Provider for Databricks account&lt;BR /&gt;provider "databricks" {&lt;BR /&gt;alias = "azure_account"&lt;BR /&gt;host = "&lt;A href="https://accounts.azuredatabricks.net" target="_blank"&gt;https://accounts.azuredatabricks.net&lt;/A&gt;"&lt;BR /&gt;account_id = var.account_id&lt;BR /&gt;azure_client_id = var.client_id&lt;BR /&gt;azure_client_secret = var.client_secret&lt;BR /&gt;}&lt;BR /&gt;I execute all the Terraform tasks from a shell script. Within this script, we use a Databricks CLI command to check whether the workspace is assigned to a metastore:&lt;BR /&gt;&lt;BR /&gt;sh&lt;BR /&gt;databricks auth login --host &lt;A href="https://accounts.azuredatabricks.net" target="_blank"&gt;https://accounts.azuredatabricks.net&lt;/A&gt; --account-id "$account_id"&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;assignment&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;$(&lt;/SPAN&gt;&lt;SPAN&gt;databricks&lt;/SPAN&gt;&lt;SPAN&gt; account metastore-assignments get "&lt;/SPAN&gt;&lt;SPAN&gt;$workspace_id&lt;/SPAN&gt;&lt;SPAN&gt;" &lt;/SPAN&gt;&lt;SPAN&gt;2&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;/dev/null)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;However, I am unable to authenticate since the command attempts to authenticate using a client ID and client secret.&lt;/P&gt;&lt;P&gt;Is there a way to authenticate using the client ID and client secret directly with the Databricks CLI? If not, can you suggest any alternative methods to achieve this authentication?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jv_v_0-1718116490905.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/8214i74159B4BB3368A6D/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="jv_v_0-1718116490905.png" alt="jv_v_0-1718116490905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 14:35:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/authenticating-to-accounts-console-using-client-id-and-secret/m-p/72338#M1862</guid>
      <dc:creator>jv_v</dc:creator>
      <dc:date>2024-06-11T14:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Authenticating to Accounts Console Using Client ID and Secret via Terraform and Databricks CLI</title>
      <link>https://community.databricks.com/t5/data-governance/authenticating-to-accounts-console-using-client-id-and-secret/m-p/72461#M1866</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can follow instructions in the following doc to configure OAuth machine-to-machine authentication using Service Principal.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.databricks.com/en/dev-tools/cli/authentication.html#oauth-machine-to-machine-m2m-authentication" target="_blank"&gt;https://docs.databricks.com/en/dev-tools/cli/authentication.html#oauth-machine-to-machine-m2m-authentication&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once it is configured properly, you should be able to run Databricks CLI, then run following command to confirm metastore assignment for a given workspace:&lt;/P&gt;
&lt;PRE class="p1"&gt;&lt;SPAN class="s1"&gt;databricks account metastore-assignments get &amp;lt;&amp;lt;WORKSPACE_ID&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 20:42:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/authenticating-to-accounts-console-using-client-id-and-secret/m-p/72461#M1866</guid>
      <dc:creator>JianWu</dc:creator>
      <dc:date>2024-06-11T20:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Authenticating to Accounts Console Using Client ID and Secret via Terraform and Databricks CLI</title>
      <link>https://community.databricks.com/t5/data-governance/authenticating-to-accounts-console-using-client-id-and-secret/m-p/74865#M1895</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am attempting to complete OAuth M2M (Machine-to-Machine) authentication as advised, but I keep encountering the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "error": "invalid_request",&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "error_id": "*****************",&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "error_description": "Invalid request"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a summary of my current setup and the steps I have taken:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Script used to generate the tocken&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;export CLIENT_ID=&amp;lt;client id&amp;gt;&lt;BR /&gt;export CLIENT_SECRET=clent secret&lt;BR /&gt;&lt;BR /&gt;curl --request POST \&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--url '&lt;A class="" title="https://accounts.azuredatabricks.net/oidc/accounts/%3caccoutnt" href="https://accounts.azuredatabricks.net/oidc/accounts/&amp;lt;accoutnt" target="_blank" rel="noreferrer noopener"&gt;https://accounts.azuredatabricks.net/oidc/accounts/&amp;lt;accoutnt id&amp;gt;/v1/token \'&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--user "$CLIENT_ID:$CLIENT_SECRET" \&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--data 'grant_type=client_credentials&amp;amp;scope=all-apis'&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 13:33:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/authenticating-to-accounts-console-using-client-id-and-secret/m-p/74865#M1895</guid>
      <dc:creator>jv_v</dc:creator>
      <dc:date>2024-06-18T13:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Authenticating to Accounts Console Using Client ID and Secret via Terraform and Databricks CLI</title>
      <link>https://community.databricks.com/t5/data-governance/authenticating-to-accounts-console-using-client-id-and-secret/m-p/74889#M1896</link>
      <description>&lt;P&gt;First, run following commands in shell, please replace placeholder according to your environment:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;export CLIENT_ID=&amp;lt;client id&amp;gt;
export CLIENT_SECRET=&amp;lt;client secret&amp;gt;
export TOKEN_EP=https://accounts.cloud.databricks.com/oidc/accounts/&amp;lt;databricks account id&amp;gt;/v1/token&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;then run this command to generate token:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;curl --request POST --url $TOKEN_EP --user "$CLIENT_ID:$CLIENT_SECRET" --data 'grant_type=client_credentials&amp;amp;scope=all-apis'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Please make sure you follow following instructions to create client id/secret for your service principal, it should be created at account level instead of workspace level.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.databricks.com/en/dev-tools/auth/oauth-m2m.html#step-3-create-an-oauth-secret-for-a-service-principal" target="_blank"&gt;https://docs.databricks.com/en/dev-tools/auth/oauth-m2m.html#step-3-create-an-oauth-secret-for-a-service-principal&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 16:15:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/authenticating-to-accounts-console-using-client-id-and-secret/m-p/74889#M1896</guid>
      <dc:creator>JianWu</dc:creator>
      <dc:date>2024-06-18T16:15:35Z</dc:date>
    </item>
  </channel>
</rss>

