Support Questions

Find answers, ask questions, and share your expertise

Cloudera Manager API : HTTP Error 401: basic auth failed (error 401)

avatar
New Contributor

So, I am using the basic text from the api site. I enter my username and password that matches with the Cloudera manager and I am still getting an error. Do I need to add more code like a request authrozation? What exactly is a Kerberos authroization? 

 

cm_api.api_client.ApiException: HTTP Error 401: basic auth failed (error 401)

---------------------


# Get a handle to the API client

from cm_api.api_client import ApiResource

cm_host = "cm-host"
api = ApiResource(cm_host, username="admin", password="admin")

# Get a list of all clusters
cdh4 = None
for c in api.get_all_clusters():
  print c.name
  if c.version == "CDH4":
    cdh4 = c

## -- Output --
# Cluster 1 - CDH4
# Cluster 2 - CDH3

3 REPLIES 3

avatar
Master Guru

@don1123,

 

The most direct explanation is that your user and password strings fail authentication.

Can you check to make sure that you can log in with "admin" as your username and password via the Cloudera Manager User Interface?

 

An HTTP 401 is "authentication required" and that is what you would get if the user/pass was incorrect.

avatar
New Contributor

The server belongs the company, so I am using my registered account to login. I am looking at it and it is a SAML

External Authentication Type, if that is related to my problem or not.

avatar
Master Guru

@don1123

 

API calls cannot use SAML for authentication, so "local" database login will need to occur in order for your authentication to succeed.  This means you need a user/password created in Cloudera Manager to be able to utilize it via the API.

 

You can test your "local" (non-SAML) authentication in Cloudera Manager by navigating to the following URL:

 

http://cm_host:cm_port/cmf/localLogin

 

This will bypass SAML authentication and allow you to log in as a user who is in the Cloudera Manager database.