import splunklib.client as client
HOST = "Host IP"
PORT = 8089
USERNAME = "my username"
PASSWORD = "password"
# Create a Service instance and log in
service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD)
# Print installed apps to the console to verify login
for app in service.apps:
print app.name
Traceback (most recent call last):
File "D:\Users\name\Downloads\splunk-sdk-python-1.6.5\splunklib\binding.py", line 861, in login
cookie="1") # In Splunk 6.2+, passing "cookie=1" will return the "set-cookie" header
File "D:\Users\name\Downloads\splunk-sdk-python-1.6.5\splunklib\binding.py", line 1208, in post
return self.request(url, message)
File "D:\Users\name\Downloads\splunk-sdk-python-1.6.5\splunklib\binding.py", line 1228, in request
raise HTTPError(response)
splunklib.binding.HTTPError: HTTP 401 Unauthorized -- Login failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Users\name\pyton programs\test.py", line 20, in
password=PASSWORD)
File "D:\Users\name\Downloads\splunk-sdk-python-1.6.5\splunklib\client.py", line 325, in connect
s.login()
File "D:\Users\name\Downloads\splunk-sdk-python-1.6.5\splunklib\binding.py", line 869, in login
raise AuthenticationError("Login failed.", he)
splunklib.binding.AuthenticationError: Login failed.
facing same issue, have you resolved this one?
I have the same issue. I found this "you must contact Splunk to ensure that the credentials being used have access to the API on port 8089"
here:
https://interset.zendesk.com/hc/en-us/articles/115004545887-com-splunk-HttpException-HTTP-401-Login-...
Please respond if you managed to get this working, I am struggling to get a response from Splunk (I cannot raise a request ticket).