<?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: how to connect to livy with kerberos authentication on cloudera cluster in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350225#M235925</link>
    <description>&lt;P&gt;We can also try running the below python code:&lt;/P&gt;&lt;P&gt;1. Run the kinit command.&lt;/P&gt;&lt;P&gt;2. Run the code in Python shell:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import json, pprint, requests, textwrap
from requests_kerberos import HTTPKerberosAuth

host='http://localhost:8998'
headers = {'Requested-By': 'livy','Content-Type': 'application/json','X-Requested-By': 'livy'}
auth=HTTPKerberosAuth()

data={'className': 'org.apache.spark.examples.SparkPi','jars': ["/tmp/spark-examples_2.11-2.4.7.7.1.7.1000-141.jar"],'name': 'livy-test1', 'file': 'hdfs:///tmp/spark-examples_2.11-2.4.7.7.1.7.1000-141.jar','args': ["10"]}
r0 = requests.post(host + '/batches', data=json.dumps(data), headers=headers, auth=auth)
r0.json()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Aug 2022 10:57:02 GMT</pubDate>
    <dc:creator>Deepan_N</dc:creator>
    <dc:date>2022-08-17T10:57:02Z</dc:date>
    <item>
      <title>how to connect to livy with kerberos authentication on cloudera cluster</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350170#M235906</link>
      <description>&lt;P&gt;hello cloudera community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we have installed livy directly on a cloudera cluster host and we are now trying to connect to livy now using kerberos but we are getting the following error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;lt;html&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;head&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;title&amp;gt;Error 401 &amp;lt;/title&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;/head&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;body&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;h2&amp;gt;HTTP ERROR: 401&amp;lt;/h2&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;p&amp;gt;Problem accessing /sessions. Reason:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;pre&amp;gt; Authentication required&amp;lt;/pre&amp;gt;&amp;lt;/p&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;hr /&amp;gt;&amp;lt;a href="&lt;A href="http://eclipse.org/jetty" target="_blank" rel="noopener"&gt;http://eclipse.org/jetty&lt;/A&gt;"&amp;gt;Powered by Jetty:// 9.3.24.v20180605&amp;lt;/a&amp;gt;&amp;lt;hr/&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;/body&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;/html&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how can we make this connection to retest livy?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we are testing the connection with python3 script as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE&gt;
import json, pprint, requests, textwrap
from requests_kerberos import HTTPKerberosAuth
host='http://localhost:8998'
data = {'kind': 'spark'}
headers = {'Requested-By': 'livy','Content-Type': 'application/json'}
auth=HTTPKerberosAuth()
r0 = requests.post(host + '/sessions', data=json.dumps(data), headers=headers,auth=auth)
r0.json()
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 00:46:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350170#M235906</guid>
      <dc:creator>yagoaparecidoti</dc:creator>
      <dc:date>2022-08-17T00:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to connect to livy with kerberos authentication on cloudera cluster</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350219#M235923</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/96163"&gt;@yagoaparecidoti&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;&lt;P&gt;- Did we get the valid kerberos ticket before running the code?&lt;/P&gt;&lt;P&gt;- Does the klist command show the valid expiry date?&lt;BR /&gt;- Check the output of the below code after running your code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;r0.headers["www-authenticate"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are we able to run the Sample Livy job using the CURL command?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steps to run the sample job:&lt;/P&gt;&lt;P&gt;1. Copy the JAR to HDFS:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# hdfs dfs -put /opt/cloudera/parcels/CDH/jars/spark-examples&amp;lt;VERSION&amp;gt;.jar /tmp&lt;/LI-CODE&gt;&lt;P&gt;2. Make sure the JAR is present.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# hdfs dfs -ls /tmp/&lt;/LI-CODE&gt;&lt;P&gt;3. CURL command to run the Spark job using Livy API.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# curl -v -u: --negotiate -X POST --data '{"className": "org.apache.spark.examples.SparkPi", "jars": ["/tmp/spark-examples&amp;lt;VERSION&amp;gt;.jar"], "name": "livy-test", "file": "hdfs:///tmp/spark-examples&amp;lt;VERSION&amp;gt;.jar", "args": [10]}' -H "Content-Type: application/json" -H "X-Requested-By: User" http://&amp;lt;LIVY_NODE&amp;gt;:&amp;lt;PORT&amp;gt;/batches&lt;/LI-CODE&gt;&lt;P&gt;4. Check for the running and completed Livy sessions.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# curl http://&amp;lt;LIVY_NODE&amp;gt;:&amp;lt;PORT&amp;gt;/batches/ | python -m json.tool&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE:&lt;BR /&gt;        * Change the JAR version ( &amp;lt;VERSION&amp;gt; ) according your CDP version.&lt;BR /&gt;        * Replace the LIVY_NODE and PORT with the actual values.&lt;BR /&gt;        * If you are running the cluster in secure mode, then make sure you have a valid Kerberos ticket and use the Kerberos authentication in curl command.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 09:51:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350219#M235923</guid>
      <dc:creator>Deepan_N</dc:creator>
      <dc:date>2022-08-17T09:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to connect to livy with kerberos authentication on cloudera cluster</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350225#M235925</link>
      <description>&lt;P&gt;We can also try running the below python code:&lt;/P&gt;&lt;P&gt;1. Run the kinit command.&lt;/P&gt;&lt;P&gt;2. Run the code in Python shell:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import json, pprint, requests, textwrap
from requests_kerberos import HTTPKerberosAuth

host='http://localhost:8998'
headers = {'Requested-By': 'livy','Content-Type': 'application/json','X-Requested-By': 'livy'}
auth=HTTPKerberosAuth()

data={'className': 'org.apache.spark.examples.SparkPi','jars': ["/tmp/spark-examples_2.11-2.4.7.7.1.7.1000-141.jar"],'name': 'livy-test1', 'file': 'hdfs:///tmp/spark-examples_2.11-2.4.7.7.1.7.1000-141.jar','args': ["10"]}
r0 = requests.post(host + '/batches', data=json.dumps(data), headers=headers, auth=auth)
r0.json()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 10:57:02 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350225#M235925</guid>
      <dc:creator>Deepan_N</dc:creator>
      <dc:date>2022-08-17T10:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to connect to livy with kerberos authentication on cloudera cluster</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350259#M235933</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/44661"&gt;@Deepan_N&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;the "&lt;STRONG&gt;kinit&lt;/STRONG&gt;" command was successfully executed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the "&lt;STRONG&gt;klist&lt;/STRONG&gt;" command returns the date of the validated ticket and I have more than 10h to use the ticket.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both modes have been tested:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;curl:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;curl -v -u: --negotiate -X POST --data '{"className": "org.apache.spark.examples.SparkPi", "jars": ["/tmp/spark-examples-1.6.0-cdh5.16.1-hadoop2.6.0-cdh5.16.1.jar"], "name": "livy-test", "file": "hdfs:///tmp/spark-examples-1.6.0-cdh5.16.1-hadoop2.6.0-cdh5.16.1.jar", "args": [10]}' -H "Content-Type: application/json" -H "X-Requested-By: User" &lt;A href="http://localhost:8998/batches" target="_blank"&gt;http://localhost:8998/batches&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;python:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import json, pprint, requests, textwrap&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;from requests_kerberos import HTTPKerberosAuth&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;host='&lt;A href="http://localhost:8998" target="_blank"&gt;http://localhost:8998&lt;/A&gt;'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;headers = {'Requested-By': 'livy','Content-Type': 'application/json','X-Requested-By': 'livy'}&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;auth=HTTPKerberosAuth()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data={'className': 'org.apache.spark.examples.SparkPi','jars': ["/tmp/spark-examples-1.6.0-cdh5.16.1-hadoop2.6.0-cdh5.16.1.jar"],'name': 'livy-test1', 'file': 'hdfs:///tmp/spark-examples-1.6.0-cdh5.16.1-hadoop2.6.0-cdh5.16.1.jar','args': ["10"]}&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;r0 = requests.post(host + '/batches', data=json.dumps(data), headers=headers, auth=auth)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;r0.json()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but unfortunately both ways return the error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;lt;html&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;head&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;title&amp;gt;Error 401 &amp;lt;/title&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;/head&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;body&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;h2&amp;gt;HTTP ERROR: 401&amp;lt;/h2&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;p&amp;gt;Problem accessing /batches. Reason:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;pre&amp;gt; Authentication required&amp;lt;/pre&amp;gt;&amp;lt;/p&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;hr /&amp;gt;&amp;lt;a href="&lt;A href="http://eclipse.org/jetty" target="_blank"&gt;http://eclipse.org/jetty&lt;/A&gt;"&amp;gt;Powered by Jetty:// 9.3.24.v20180605&amp;lt;/a&amp;gt;&amp;lt;hr/&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;/body&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;lt;/html&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS¹: the cluster has kerberos&lt;BR /&gt;PS²: the user that validated the ticket with "kinit" is the livy user that is created in AD (active directory)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ticket_kerberos_livy.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35191i7CA7FB73A0F4038C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ticket_kerberos_livy.png" alt="ticket_kerberos_livy.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 17:52:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350259#M235933</guid>
      <dc:creator>yagoaparecidoti</dc:creator>
      <dc:date>2022-08-17T17:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to connect to livy with kerberos authentication on cloudera cluster</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350415#M235966</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/96163"&gt;@yagoaparecidoti&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Can you please share the output of the below commands?&lt;BR /&gt;From the Python shell:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;r0.headers["www-authenticate"]&lt;/LI-CODE&gt;&lt;P&gt;From the bash:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# kinit
# klist
# date
# curl -v -u: --negotiate -X GET http://&amp;lt;LIVY_NODE&amp;gt;:&amp;lt;PORT&amp;gt;/batches/&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 19 Aug 2022 10:37:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350415#M235966</guid>
      <dc:creator>Deepan_N</dc:creator>
      <dc:date>2022-08-19T10:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to connect to livy with kerberos authentication on cloudera cluster</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350429#M235971</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/44661"&gt;@Deepan_N&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;by running the command below directly in python3:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;r0.headers["www-authenticate"]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;returns the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Python 3.6.8 (default, Nov 16 2020, 16:55:22)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Type "help", "copyright", "credits" or "license" for more information.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;gt;&amp;gt;&amp;gt; r0.headers["www-authenticate"]&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Traceback (most recent call last):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;NameError: name 'r0' is not defined&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;below is the screenshot of the commands executed in bash:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="comands_error_livy.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/35262i834DA4E01FEF057B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="comands_error_livy.png" alt="comands_error_livy.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 12:51:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-connect-to-livy-with-kerberos-authentication-on/m-p/350429#M235971</guid>
      <dc:creator>yagoaparecidoti</dc:creator>
      <dc:date>2022-08-19T12:51:37Z</dc:date>
    </item>
  </channel>
</rss>

