Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to authenticate using hadoop delegation token file? #152

Open
Nithanaroy opened this issue Mar 22, 2020 · 1 comment
Open

How to authenticate using hadoop delegation token file? #152

Nithanaroy opened this issue Mar 22, 2020 · 1 comment

Comments

@Nithanaroy
Copy link

client = KerberosClient('http://....:50070', delegate=True)
client.list('hdfs:///')

produces this error

INFO:hdfs.client:Instantiated <KerberosClient(url='http://*****:50070')>.
INFO:hdfs.client:Listing 'hdfs:///'.
DEBUG:hdfs.client:Resolved path '/' to '/'.
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): *****:50070
DEBUG:urllib3.connectionpool:http://*****:50070 "GET /webhdfs/v1/?op=GETHOMEDIRECTORY HTTP/1.1" 401 1538
DEBUG:requests_kerberos.kerberos_:handle_401(): Handling: 401
ERROR:requests_kerberos.kerberos_:generate_request_header(): authGSSClientStep() failed:
Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.7/site-packages/requests_kerberos/kerberos_.py", line 230, in generate_request_header
    negotiate_resp_value)
kerberos.GSSError: (('Unspecified GSS failure.  Minor code may provide more information', 851968), ('No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0)', -1765328243))
ERROR:requests_kerberos.kerberos_:(('Unspecified GSS failure.  Minor code may provide more information', 851968), ('No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0)', -1765328243))
Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.7/site-packages/requests_kerberos/kerberos_.py", line 230, in generate_request_header
    negotiate_resp_value)
kerberos.GSSError: (('Unspecified GSS failure.  Minor code may provide more information', 851968), ('No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0)', -1765328243))
DEBUG:requests_kerberos.kerberos_:handle_401(): returning <Response [401]>
DEBUG:requests_kerberos.kerberos_:handle_response(): returning <Response [401]>
DEBUG:requests_kerberos.kerberos_:handle_response() has seen 0 401 responses
DEBUG:requests_kerberos.kerberos_:handle_401(): Handling: 401
ERROR:requests_kerberos.kerberos_:generate_request_header(): authGSSClientStep() failed:
Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.7/site-packages/requests_kerberos/kerberos_.py", line 230, in generate_request_header
    negotiate_resp_value)
kerberos.GSSError: (('Unspecified GSS failure.  Minor code may provide more information', 851968), ('No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0)', -1765328243))
ERROR:requests_kerberos.kerberos_:(('Unspecified GSS failure.  Minor code may provide more information', 851968), ('No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0)', -1765328243))
Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.7/site-packages/requests_kerberos/kerberos_.py", line 230, in generate_request_header
    negotiate_resp_value)
kerberos.GSSError: (('Unspecified GSS failure.  Minor code may provide more information', 851968), ('No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_0)', -1765328243))
DEBUG:requests_kerberos.kerberos_:handle_401(): returning <Response [401]>
DEBUG:requests_kerberos.kerberos_:handle_response(): returning <Response [401]>
DEBUG:requests_kerberos.kerberos_:handle_response() has seen 1 401 responses
DEBUG:requests_kerberos.kerberos_:handle_response(): returning 401 <Response [401]>
ERROR:hdfs.client:b'<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>\n<title>Error 401 Authentication required. ....\n'

I know the location of hadoop token file. But I'm not sure how to convey this to the library. I'm able to run hadoop fs ... command successfully. Do I need to set any environment variables?

@Nithanaroy Nithanaroy changed the title How to authenticate using Kerberos delegation token file? How to authenticate using hadoop delegation token file? Mar 22, 2020
@Nithanaroy
Copy link
Author

Nithanaroy commented Mar 22, 2020

I tried using TokenClient by passing token file path, raw token file contents, base64 encoded contents. I get a 500 or 403 errors.

with open("hdfs-delegation-token", "rb") as f:
    binary_token = f.read()
    base64_encoded_data = base64.b64encode(binary_token)
    token = base64_encoded_data.decode('utf-8')

client = hdfs.TokenClient("http://*****:50070", token=token)
client.list("hdfs:///data.txt")

403 Error: HdfsError: Failed to obtain user group information: java.io.EOFException
500 Error: None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant