<?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 databricks sdk for python authentication failing in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/databricks-sdk-for-python-authentication-failing/m-p/108998#M43197</link>
    <description>&lt;P&gt;I am trying to use databricks sdk for python to do some account level operations like creating groups and created a databricks config file locally n provided the profile name as argument to AccountClient but authentication keeps failing. the same config file is working fine with CLI so any insights on how to provide auth details for accountclient method:&lt;/P&gt;&lt;P&gt;My current code is like this:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;from databricks.sdk import AccountClient&lt;BR /&gt;a = AccountClient(profile="account")&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;PRE&gt;my databirckscfg has below details:&lt;BR /&gt;[account]&lt;BR /&gt;host = &lt;A href="https://accounts.databricks.net" target="_blank"&gt;https://accounts.databricks.net&lt;/A&gt;&lt;BR /&gt;account_id = &amp;lt;&amp;gt;&lt;BR /&gt;client_id = &amp;lt;&amp;gt;&lt;BR /&gt;client_secret=&amp;lt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2025 17:04:08 GMT</pubDate>
    <dc:creator>Sujith_i</dc:creator>
    <dc:date>2025-02-05T17:04:08Z</dc:date>
    <item>
      <title>databricks sdk for python authentication failing</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-sdk-for-python-authentication-failing/m-p/108998#M43197</link>
      <description>&lt;P&gt;I am trying to use databricks sdk for python to do some account level operations like creating groups and created a databricks config file locally n provided the profile name as argument to AccountClient but authentication keeps failing. the same config file is working fine with CLI so any insights on how to provide auth details for accountclient method:&lt;/P&gt;&lt;P&gt;My current code is like this:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;from databricks.sdk import AccountClient&lt;BR /&gt;a = AccountClient(profile="account")&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;PRE&gt;my databirckscfg has below details:&lt;BR /&gt;[account]&lt;BR /&gt;host = &lt;A href="https://accounts.databricks.net" target="_blank"&gt;https://accounts.databricks.net&lt;/A&gt;&lt;BR /&gt;account_id = &amp;lt;&amp;gt;&lt;BR /&gt;client_id = &amp;lt;&amp;gt;&lt;BR /&gt;client_secret=&amp;lt;&amp;gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 17:04:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-sdk-for-python-authentication-failing/m-p/108998#M43197</guid>
      <dc:creator>Sujith_i</dc:creator>
      <dc:date>2025-02-05T17:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: databricks sdk for python authentication failing</title>
      <link>https://community.databricks.com/t5/data-engineering/databricks-sdk-for-python-authentication-failing/m-p/137026#M50685</link>
      <description>&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Authentication for account-level operations with Databricks SDK for Python requires more than just referencing the profile name in your local&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;.databrickscfg&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;file. While the CLI consults&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;.databrickscfg&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;for profiles and can use them directly, the SDK's&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;AccountClient&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;often does not automatically read the config file for account-level authentication the way CLI does.​&lt;/P&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;Correct Authentication Approach&lt;/H2&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;You need to provide explicit authentication parameters when initializing&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;AccountClient&lt;/CODE&gt;, as the SDK does not natively pick up&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;.databrickscfg&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;profiles for account-level OAuth or service principal flows. The recommended approach is:​&lt;/P&gt;
&lt;DIV class="w-full md:max-w-[90vw]"&gt;
&lt;DIV class="codeWrapper text-light selection:text-super selection:bg-super/10 my-md relative flex flex-col rounded font-mono text-sm font-normal bg-subtler"&gt;
&lt;DIV class="translate-y-xs -translate-x-xs bottom-xl mb-xl flex h-0 items-start justify-end md:sticky md:top-[100px]"&gt;
&lt;DIV class="overflow-hidden rounded-full border-subtlest ring-subtlest divide-subtlest bg-base"&gt;
&lt;DIV class="border-subtlest ring-subtlest divide-subtlest bg-subtler"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="-mt-xl"&gt;
&lt;DIV&gt;
&lt;DIV class="text-quiet bg-subtle py-xs px-sm inline-block rounded-br rounded-tl-[3px] font-thin" data-testid="code-language-indicator"&gt;python&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;CODE&gt;&lt;SPAN class="token token"&gt;from&lt;/SPAN&gt; databricks&lt;SPAN class="token token punctuation"&gt;.&lt;/SPAN&gt;sdk &lt;SPAN class="token token"&gt;import&lt;/SPAN&gt; AccountClient

a &lt;SPAN class="token token operator"&gt;=&lt;/SPAN&gt; AccountClient&lt;SPAN class="token token punctuation"&gt;(&lt;/SPAN&gt;
    host&lt;SPAN class="token token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token token"&gt;"&lt;A href="https://accounts.databricks.net" target="_blank"&gt;https://accounts.databricks.net&lt;/A&gt;"&lt;/SPAN&gt;&lt;SPAN class="token token punctuation"&gt;,&lt;/SPAN&gt;
    account_id&lt;SPAN class="token token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token token"&gt;"&amp;lt;account_id&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="token token punctuation"&gt;,&lt;/SPAN&gt;
    client_id&lt;SPAN class="token token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token token"&gt;"&amp;lt;client_id&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="token token punctuation"&gt;,&lt;/SPAN&gt;
    client_secret&lt;SPAN class="token token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token token"&gt;"&amp;lt;client_secret&amp;gt;"&lt;/SPAN&gt;
&lt;SPAN class="token token punctuation"&gt;)&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Here, all necessary details from your&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;.databrickscfg&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;profile are provided as keyword arguments directly to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;AccountClient&lt;/CODE&gt;. This step is crucial for account-level endpoints because notebook-native/workspace authentication doesn't work for account-wide operations; and the SDK doesn't read account-level config profiles by default.​&lt;/P&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;Why CLI Works but SDK Fails&lt;/H2&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;The CLI searches for authentication information in environment variables or in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;.databrickscfg&lt;/CODE&gt;, but the Python SDK's account-level client expects details to be explicitly supplied, especially for OAuth/service principal flows. This discrepancy stems from CLI having a more robust config profile discovery than the SDK for account-level resources.​&lt;/P&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;Additional Tips&lt;/H2&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Ensure that the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;host&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;matches your cloud provider (e.g., AWS, Azure, GCP—URLs differ).​&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Double-check you have account admin privileges for these operations.​&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;The config profile method works for workspace-level clients, but not for account clients.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;If you want consistent behavior for SDK and CLI, you can wrap profile extraction yourself in Python, load values from&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;.databrickscfg&lt;/CODE&gt;, and pass them explicitly when constructing&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;AccountClient&lt;/CODE&gt;.&lt;/P&gt;
&lt;H2 class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0"&gt;References&lt;/H2&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Always authenticate using OAuth with a service principal for unattended access.​&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;More details in Databricks SDK for Python authentication documentation.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 31 Oct 2025 15:09:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/databricks-sdk-for-python-authentication-failing/m-p/137026#M50685</guid>
      <dc:creator>mark_ott</dc:creator>
      <dc:date>2025-10-31T15:09:41Z</dc:date>
    </item>
  </channel>
</rss>

