<?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>question Re: Is it possible to generate a Knox token pro-grammatically? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414126#M254652</link>
    <description>&lt;P&gt;Here is another way...&amp;nbsp;&lt;/P&gt;&lt;DIV class="markdown markdown-main-panel tutor-markdown-rendering stronger enable-updated-hr-color"&gt;&lt;P&gt;Instead of basic auth (user/pass), you could use Kerberos to authenticate the request programmatically. This removes the need for hardcoded credentials.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Using Python (requests-kerberos):&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class="code-block ng-tns-c766581630-18 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation"&gt;&lt;DIV class="formatted-code-block-internal-container ng-tns-c766581630-18"&gt;&lt;DIV class="animated-opacity ng-tns-c766581630-18"&gt;&lt;DIV class="code-block-decoration header-formatted gds-emphasized-body-m ng-tns-c766581630-18 ng-star-inserted"&gt;&lt;SPAN class="ng-tns-c766581630-18"&gt;Python&lt;/SPAN&gt;&lt;DIV class="buttons ng-tns-c766581630-18 ng-star-inserted"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; requests
&lt;SPAN class="hljs-keyword"&gt;from&lt;/SPAN&gt; requests_kerberos &lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; HTTPKerberosAuth

knox_url = &lt;SPAN class="hljs-string"&gt;"https://&amp;lt;knox-host&amp;gt;:8443/gateway/knoxsso/api/v1/token"&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;# This uses your existing kinit session&lt;/SPAN&gt;
response = requests.get(knox_url, auth=HTTPKerberosAuth(), verify=&lt;SPAN class="hljs-literal"&gt;False&lt;/SPAN&gt;)

&lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; response.status_code == &lt;SPAN class="hljs-number"&gt;200&lt;/SPAN&gt;:
    token_data = response.json()
    print(&lt;SPAN class="hljs-string"&gt;f"Your Token: &lt;SPAN class="hljs-subst"&gt;{token_data['access_token']}&lt;/SPAN&gt;"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Set up a Kerberos keytab for your service account&lt;/STRONG&gt;, and use a script (Python or Java) to hit the Knox Token API using SPNEGO. This is the enterprise-standard way to automate Knox token generation without the Web UI or manual password entry.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I think there are quite a few alternatives here, java, nifi, etc&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 28 May 2026 12:40:04 GMT</pubDate>
    <dc:creator>steven-matison</dc:creator>
    <dc:date>2026-05-28T12:40:04Z</dc:date>
    <item>
      <title>Is it possible to generate a Knox token pro-grammatically?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414081#M254460</link>
      <description>&lt;P&gt;I can get a Knox token from the Web UI in CDP Private Cloud, but is it possible to get it from the API without having to use the Web UI?&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2026 13:37:35 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414081#M254460</guid>
      <dc:creator>NovSeek</dc:creator>
      <dc:date>2026-05-14T13:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to generate a Knox token pro-grammatically?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414083#M254577</link>
      <description>&lt;P&gt;Welcome to the Cloudera Community!&lt;BR /&gt;&lt;BR /&gt;To help you get the best possible solution, I have tagged our Knox experts&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/68134"&gt;@niparmar&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35149"&gt;@Scharan&lt;/a&gt;&amp;nbsp; who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;Please keep us updated on your post, and we hope you find a satisfactory solution to your query.&lt;/P&gt;</description>
      <pubDate>Thu, 14 May 2026 19:15:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414083#M254577</guid>
      <dc:creator>DianaTorres</dc:creator>
      <dc:date>2026-05-14T19:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to generate a Knox token pro-grammatically?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414085#M254579</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/146415"&gt;@NovSeek&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try follwoing&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;curl -k -c cookies3.txt -L -u knox_user:knoxpass &lt;A href="https://ccycloud-1.nightly-cm-my.root.comops.site:8443/gateway/homepage/knoxtoken/api/v1/token" target="_blank"&gt;https://ccycloud-1.nightly-cm-my.root.comops.site:8443/gateway/homepage/knoxtoken/api/v1/token&lt;/A&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;| jq -r '.access_token' &amp;gt; knox-access-token.txt&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; Knox token will be stored in&amp;nbsp;knox-access-token.txt&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;[root@ccycloud-1.nightly-cm-my.root.comops.site ~]# curl -ku Token:eyJqa3UiOiJodHRwczovL2NjeWNsb3VkLTEubmlnaHRseS1jbS1teS5yb290LmNvbW9wcy5zaXRlOjg0NDMvZ2F0ZXdheS9ob21lcGFnZS9rbm94dG9rZW4vYXBpL3YxL2p3a3MuanNvbiIsImtpZCI6Ikh2cVJaVjBkRk1US0pGSEpUWnJiQjN1MWlHOVA2cGNsOFpFLWU5SzJXTzQiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJrbm94dWkiLCJhdWQiOiJjZHAtcHJveHktdG9rZW4iLCJqa3UiOiJodHRwczovL2NjeWNsb3VkLTEubmlnaHRseS1jbS1teS5yb290LmNvbW9wcy5zaXRlOjg0NDMvZ2F0ZXdheS9ob21lcGFnZS9rbm94dG9rZW4vYXBpL3YxL2p3a3MuanNvbiIsImtpZCI6Ikh2cVJaVjBkRk1US0pGSEpUWnJiQjN1MWlHOVA2cGNsOFpFLWU5SzJXTzQiLCJpc3MiOiJLTk9YU1NPIiwiZXhwIjoxNzc4ODEyMTU3LCJtYW5hZ2VkLnRva2VuIjoidHJ1ZSIsImtub3guaWQiOiJiOThjYjNiMi0yNmNmLTQ1NTktOWJiMi1kNGRhOTljYjg0ODMifQ.wejWLyybDpYcGGsJF_VQA0GSSXAlLQsTM2H9z9-Yn-WWYfjzGq-a_h04ShEW0hgMaSuf2lVQKx16JKaNRk5-FPXP7EYLl1MFEmAsCMZjDFaRdcP8gqDOz6HDtWWveaQ51UiUOHpit2PsYZjxlu8MD_iOQn_Lpg92558VxiQKZdHO7lJbPQgDcOjPbbIPM-ZdpZOUbbJyj3Z1HsOfJHw2BogfpQe9TuLfN7MVjUvO5l6tbwh9qeV75jWBuiB6Iij6dp4lewKTrdaAIH-Hp8laCJbF13bPgFitOkg_fBln8dpJ8XNNoltriZLbZ01az1Oq4hY0iZSRbiglOJXP2F2miw &lt;A href="https://ccycloud-1.nightly-cm-my.root.comops.site:8443/gateway/cdp-proxy-token/webhdfs/v1?op=LISTSTATUS" target="_blank"&gt;https://ccycloud-1.nightly-cm-my.root.comops.site:8443/gateway/cdp-proxy-token/webhdfs/v1?op=LISTSTATUS&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;{"FileStatuses":{"FileStatus":[{"accessTime":0,"blockSize":0,"childrenNum":12,"fileId":16415,"group":"hbase","length":0,"modificationTime":1778772940944,"owner":"hbase","pathSuffix":"hbase","permission":"755","replication":0,"storagePolicy":0,"type":"DIRECTORY"},{"accessTime":0,"blockSize":0,"childrenNum":1,"fileId":16386,"group":"supergroup","length":0,"modificationTime":1778513008087,"owner":"hdfs","pathSuffix":"ranger","permission":"755","replication":0,"storagePolicy":0,"type":"DIRECTORY"},{"accessTime":0,"blockSize":0,"childrenNum":0,"fileId":16417,"group":"solr","length":0,"modificationTime":1778513048696,"owner":"solr","pathSuffix":"solr-infra","permission":"775","replication":0,"storagePolicy":0,"type":"DIRECTORY"},{"accessTime":0,"blockSize":0,"childrenNum":3,"fileId":16412,"group":"supergroup","length":0,"modificationTime":1778516233701,"owner":"hdfs","pathSuffix":"tmp","permission":"1777","replication":0,"storagePolicy":0,"type":"DIRECTORY"},{"accessTime":0,"blockSize":0,"childrenNum":13,"fileId":16394,"group":"supergroup","length":0,"modificationTime":1778578527265,"owner":"hdfs","pathSuffix":"user","permission":"755","replication":0,"storagePolicy":0,"type":"DIRECTORY"},{"accessTime":0,"blockSize":0,"childrenNum":1,"fileId":16399,"group":"supergroup","length":0,"modificationTime":1778513044819,"owner":"hdfs","pathSuffix":"warehouse","permission":"755","replication":0,"storagePolicy":0,"type":"DIRECTORY"},{"accessTime":0,"blockSize":0,"childrenNum":1,"fileId":16407,"group":"supergroup","length":0,"modificationTime":1778513047786,"owner":"hdfs","pathSuffix":"yarn","permission":"755","replication":0,"storagePolicy":0,"type":"DIRECTORY"}]}}[root@ccycloud-1.nightly-cm-my.root.comops.site ~]# &lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2026 01:33:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414085#M254579</guid>
      <dc:creator>vamsi_redd</dc:creator>
      <dc:date>2026-05-15T01:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to generate a Knox token pro-grammatically?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414086#M254580</link>
      <description>&lt;P&gt;Thanks for the reply. That is valid but not quite what I want to do. I am trying to do it without having the cookie.txt file. I think I need to set up an additional topology that has basic/ldap auth and use that to generate the Knox token.&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2026 07:40:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414086#M254580</guid>
      <dc:creator>NovSeek</dc:creator>
      <dc:date>2026-05-15T07:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to generate a Knox token pro-grammatically?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414099#M254619</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/146415"&gt;@NovSeek&lt;/a&gt;&amp;nbsp;I believe the sample above is just demonstrating use of API call.&amp;nbsp; You should be able to complete the same outcome in any other manner (e.g. not curl to a text file) programaticallly against the CM/Knox api.&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2026 11:54:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414099#M254619</guid>
      <dc:creator>steven-matison</dc:creator>
      <dc:date>2026-05-20T11:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to generate a Knox token pro-grammatically?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414117#M254645</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/146415"&gt;@NovSeek&lt;/a&gt;&amp;nbsp;Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future. If you are still experiencing the issue, can you provide more information? Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2026 18:57:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414117#M254645</guid>
      <dc:creator>DianaTorres</dc:creator>
      <dc:date>2026-05-26T18:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to generate a Knox token pro-grammatically?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414122#M254648</link>
      <description>&lt;P&gt;No it has not.&lt;/P&gt;</description>
      <pubDate>Wed, 27 May 2026 17:10:40 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414122#M254648</guid>
      <dc:creator>NovSeek</dc:creator>
      <dc:date>2026-05-27T17:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to generate a Knox token pro-grammatically?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414126#M254652</link>
      <description>&lt;P&gt;Here is another way...&amp;nbsp;&lt;/P&gt;&lt;DIV class="markdown markdown-main-panel tutor-markdown-rendering stronger enable-updated-hr-color"&gt;&lt;P&gt;Instead of basic auth (user/pass), you could use Kerberos to authenticate the request programmatically. This removes the need for hardcoded credentials.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Using Python (requests-kerberos):&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class="code-block ng-tns-c766581630-18 ng-animate-disabled ng-trigger ng-trigger-codeBlockRevealAnimation"&gt;&lt;DIV class="formatted-code-block-internal-container ng-tns-c766581630-18"&gt;&lt;DIV class="animated-opacity ng-tns-c766581630-18"&gt;&lt;DIV class="code-block-decoration header-formatted gds-emphasized-body-m ng-tns-c766581630-18 ng-star-inserted"&gt;&lt;SPAN class="ng-tns-c766581630-18"&gt;Python&lt;/SPAN&gt;&lt;DIV class="buttons ng-tns-c766581630-18 ng-star-inserted"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; requests
&lt;SPAN class="hljs-keyword"&gt;from&lt;/SPAN&gt; requests_kerberos &lt;SPAN class="hljs-keyword"&gt;import&lt;/SPAN&gt; HTTPKerberosAuth

knox_url = &lt;SPAN class="hljs-string"&gt;"https://&amp;lt;knox-host&amp;gt;:8443/gateway/knoxsso/api/v1/token"&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;# This uses your existing kinit session&lt;/SPAN&gt;
response = requests.get(knox_url, auth=HTTPKerberosAuth(), verify=&lt;SPAN class="hljs-literal"&gt;False&lt;/SPAN&gt;)

&lt;SPAN class="hljs-keyword"&gt;if&lt;/SPAN&gt; response.status_code == &lt;SPAN class="hljs-number"&gt;200&lt;/SPAN&gt;:
    token_data = response.json()
    print(&lt;SPAN class="hljs-string"&gt;f"Your Token: &lt;SPAN class="hljs-subst"&gt;{token_data['access_token']}&lt;/SPAN&gt;"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Set up a Kerberos keytab for your service account&lt;/STRONG&gt;, and use a script (Python or Java) to hit the Knox Token API using SPNEGO. This is the enterprise-standard way to automate Knox token generation without the Web UI or manual password entry.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I think there are quite a few alternatives here, java, nifi, etc&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 May 2026 12:40:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Is-it-possible-to-generate-a-Knox-token-pro-grammatically/m-p/414126#M254652</guid>
      <dc:creator>steven-matison</dc:creator>
      <dc:date>2026-05-28T12:40:04Z</dc:date>
    </item>
  </channel>
</rss>

