title: Connect to HDFS with Kerberos Authentication using Python
body: <p>I am trying to connect to HDFS protected with Kerberos authentication. I have following details but dont know how to proceed. </p>
  
  <pre><code>User
  Password
  Realm
  HttpFs Url
  </code></pre>
  
  <p>I tried below code but getting Authentication error:</p>
  
  <pre><code>from hdfs.ext.kerberos import KerberosClient
  import requests
  import logging
  
  logging.basicConfig(level=logging.DEBUG)
  
  session = requests.Session()
  session.verify = False
  
  client = KerberosClient(url='http://x.x.x.x:abcd', session=session, 
  mutual_auth='REQUIRED',principal='abcdef@LMNOPQ')
  
  print(client.list('/'))
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>INFO:hdfs.client:Instantiated   
  &lt;KerberosClient(url=http://x.x.x.x:abcd)&gt;.
  INFO:hdfs.client:Listing '/'.
  DEBUG:hdfs.client:Resolved path '/' to '/'.
  DEBUG:hdfs.client:Resolved path '/' to '/'.
  DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 
  DEBUG:urllib3.connectionpool:http://x.x.x.x:abcd "GET /webhdfs/v1/? 
  op=LISTSTATUS HTTP/1.1" 401 997
  DEBUG:requests_kerberos.kerberos_:handle_401(): Handling: 401
  ERROR:requests_kerberos.kerberos_:generate_request_header(): authGSSClientInit() failed:
  Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests_kerberos/kerberos_.py", line 213, in generate_request_header
  gssflags=gssflags, principal=self.principal)
  kerberos.GSSError: ((' No credentials were supplied, or the credentials were unavailable or inaccessible.', 458752), ('unknown mech-code 0 for mech unknown', 0))
  ERROR:requests_kerberos.kerberos_:((' No credentials were supplied, or the credentials were unavailable or inaccessible.', 458752), ('unknown mech-code 0 for mech unknown', 0))
  Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests_kerberos/kerberos_.py", line 213, in generate_request_header
  gssflags=gssflags, principal=self.principal)
  kerberos.GSSError: ((' No credentials were supplied, or the credentials were unavailable or inaccessible.', 458752), ('unknown mech-code 0 for mech unknown', 0))
  DEBUG:requests_kerberos.kerberos_:handle_401(): returning &lt;Response [401]&gt;
  DEBUG:requests_kerberos.kerberos_:handle_response(): returning &lt;Response [401]&gt;
  </code></pre>
  
  <p>I have password also, but dont know where to provide it.</p>