<?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: cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401) in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/60973#M65250</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/24296"&gt;@ParidaAbinash&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to use the API, you must provide&amp;nbsp;authenticate to CM.&amp;nbsp; See the example here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://cloudera.github.io/cm_api/docs/python-client/" target="_blank"&gt;https://cloudera.github.io/cm_api/docs/python-client/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="c"&gt;# Get a handle to the API client&lt;/SPAN&gt;
&lt;SPAN class="kn"&gt;from&lt;/SPAN&gt; &lt;SPAN class="nn"&gt;cm_api.api_client&lt;/SPAN&gt; &lt;SPAN class="kn"&gt;import&lt;/SPAN&gt; &lt;SPAN class="n"&gt;ApiResource&lt;/SPAN&gt;

&lt;SPAN class="n"&gt;cm_host&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"cm-host"&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;api&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;ApiResource&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;cm_host&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;username&lt;/SPAN&gt;&lt;SPAN class="o"&gt;=&lt;/SPAN&gt;&lt;SPAN class="s"&gt;"admin"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;password&lt;/SPAN&gt;&lt;SPAN class="o"&gt;=&lt;/SPAN&gt;&lt;SPAN class="s"&gt;"admin"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="c"&gt;# Get a list of all clusters&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;cdh4&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="bp"&gt;None&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;for&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c&lt;/SPAN&gt; &lt;SPAN class="ow"&gt;in&lt;/SPAN&gt; &lt;SPAN class="n"&gt;api&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;get_all_clusters&lt;/SPAN&gt;&lt;SPAN class="p"&gt;():&lt;/SPAN&gt;
  &lt;SPAN class="k"&gt;print&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;name&lt;/SPAN&gt;
  &lt;SPAN class="k"&gt;if&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;version&lt;/SPAN&gt; &lt;SPAN class="o"&gt;==&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"CDH4"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="n"&gt;cdh4&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c&lt;/SPAN&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Oct 2017 21:19:24 GMT</pubDate>
    <dc:creator>bgooley</dc:creator>
    <dc:date>2017-10-16T21:19:24Z</dc:date>
    <item>
      <title>cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/57713#M65247</link>
      <description>&lt;P&gt;Hi Friends,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Getting the following exception:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CM is on the same host where I am executing the python script. Seems a very basic error. Passing admin CM credentials. Seeking pointers to&amp;nbsp;&lt;/P&gt;&lt;P&gt;- which port is it using?&lt;/P&gt;&lt;P&gt;- do I have to enable CM REST API?&lt;/P&gt;&lt;P&gt;- anyothers?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Complete stack trace.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[rizwmian@w0575oslshcea01 cluster_diff]$ python --version&lt;BR /&gt;Python 2.6.6&lt;BR /&gt;[rizwmian@w0575oslshcea01 cluster_diff]$ cdh.py&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "./cdh.py", line 67, in &amp;lt;module&amp;gt;&lt;BR /&gt;main()&lt;BR /&gt;File "./cdh.py", line 62, in main&lt;BR /&gt;cluster = find_cluster(api, None)&lt;BR /&gt;File "./cdh.py", line 12, in find_cluster&lt;BR /&gt;all_clusters = api.get_all_clusters()&lt;BR /&gt;File "/usr/lib/python2.6/site-packages/cm_api/api_client.py", line 128, in get_all_clusters&lt;BR /&gt;return clusters.get_all_clusters(self, view)&lt;BR /&gt;File "/usr/lib/python2.6/site-packages/cm_api/endpoints/clusters.py", line 66, in get_all_clusters&lt;BR /&gt;params=view and dict(view=view) or None)&lt;BR /&gt;File "/usr/lib/python2.6/site-packages/cm_api/endpoints/types.py", line 139, in call&lt;BR /&gt;ret = method(path, params=params)&lt;BR /&gt;File "/usr/lib/python2.6/site-packages/cm_api/resource.py", line 110, in get&lt;BR /&gt;return self.invoke("GET", relpath, params)&lt;BR /&gt;File "/usr/lib/python2.6/site-packages/cm_api/resource.py", line 73, in invoke&lt;BR /&gt;headers=headers)&lt;BR /&gt;File "/usr/lib/python2.6/site-packages/cm_api/http_client.py", line 174, in execute&lt;BR /&gt;raise self._exc_class(ex)&lt;BR /&gt;cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 13:56:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/57713#M65247</guid>
      <dc:creator>BellRizz</dc:creator>
      <dc:date>2017-07-20T13:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/57724#M65248</link>
      <description>&lt;P&gt;Figured out. Need both:&lt;BR /&gt;- username/password to connect to cm api&lt;BR /&gt;- user launching script to have valid kerberos ticket (surprising find)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks everyone. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 15:26:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/57724#M65248</guid>
      <dc:creator>BellRizz</dc:creator>
      <dc:date>2017-07-20T15:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/60967#M65249</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;i am also facing the same issue . can you please elaborate what exactly you did.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-avi&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 15:40:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/60967#M65249</guid>
      <dc:creator>ParidaAbinash</dc:creator>
      <dc:date>2017-10-16T15:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/60973#M65250</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/24296"&gt;@ParidaAbinash&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to use the API, you must provide&amp;nbsp;authenticate to CM.&amp;nbsp; See the example here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://cloudera.github.io/cm_api/docs/python-client/" target="_blank"&gt;https://cloudera.github.io/cm_api/docs/python-client/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="c"&gt;# Get a handle to the API client&lt;/SPAN&gt;
&lt;SPAN class="kn"&gt;from&lt;/SPAN&gt; &lt;SPAN class="nn"&gt;cm_api.api_client&lt;/SPAN&gt; &lt;SPAN class="kn"&gt;import&lt;/SPAN&gt; &lt;SPAN class="n"&gt;ApiResource&lt;/SPAN&gt;

&lt;SPAN class="n"&gt;cm_host&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"cm-host"&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;api&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;ApiResource&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;cm_host&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;username&lt;/SPAN&gt;&lt;SPAN class="o"&gt;=&lt;/SPAN&gt;&lt;SPAN class="s"&gt;"admin"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;password&lt;/SPAN&gt;&lt;SPAN class="o"&gt;=&lt;/SPAN&gt;&lt;SPAN class="s"&gt;"admin"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="c"&gt;# Get a list of all clusters&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;cdh4&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="bp"&gt;None&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;for&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c&lt;/SPAN&gt; &lt;SPAN class="ow"&gt;in&lt;/SPAN&gt; &lt;SPAN class="n"&gt;api&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;get_all_clusters&lt;/SPAN&gt;&lt;SPAN class="p"&gt;():&lt;/SPAN&gt;
  &lt;SPAN class="k"&gt;print&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;name&lt;/SPAN&gt;
  &lt;SPAN class="k"&gt;if&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;version&lt;/SPAN&gt; &lt;SPAN class="o"&gt;==&lt;/SPAN&gt; &lt;SPAN class="s"&gt;"CDH4"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="n"&gt;cdh4&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Oct 2017 21:19:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/60973#M65250</guid>
      <dc:creator>bgooley</dc:creator>
      <dc:date>2017-10-16T21:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/60987#M65251</link>
      <description>&lt;P&gt;Thanks ,&lt;/P&gt;&lt;P&gt;i figured out the issue.&lt;/P&gt;&lt;P&gt;i was passing the credentials but as it was a new service id , i had not added it with our hadoop group.&lt;/P&gt;&lt;P&gt;so the credential also couldnot be logged in to cloudera manager (which i hadnt checked earlier ,as it was working fine while logging into the server )&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2017 06:46:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/cm-api-api-client-ApiException-HTTP-Error-401-basic-auth/m-p/60987#M65251</guid>
      <dc:creator>ParidaAbinash</dc:creator>
      <dc:date>2017-10-17T06:46:21Z</dc:date>
    </item>
  </channel>
</rss>

