splunk-sdk-python
splunk-sdk-python copied to clipboard
login routine does not follow HTTP redirects?
I am using the 1.1.0 release currently available in pip. I attempt to connect to my local splunk 6.0 install using the following:
service.client.connect(
host='localhost',
scheme='https',
port=8443,
app='myapp',
username="myuser",
password="********")
But this fails like so:
Traceback (most recent call last):
File "./trtool.py", line 188, in <module>
session_report.run_report(subargs[0])
File "/home/brian/tableau-reporting/sessions.py", line 668, in run_report
self.connect_splunk()
File "/home/brian/tableau-reporting/sessions.py", line 665, in connect_splunk
password="MappyTabl3au")
File "/usr/local/lib/python2.7/dist-packages/splunklib/client.py", line 289, in connect
return Service(**kwargs).login()
File "/usr/local/lib/python2.7/dist-packages/splunklib/binding.py", line 753, in login
session = XML(body).findtext("./sessionKey")
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1302, in XML
return parser.close()
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1655, in close
self._raiseerror(v)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1507, in _raiseerror
raise err
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
I added some debug printing and found that the library is getting a 303 redirecting to https://localhost/en-US/services/auth/login. Manually following this redirect reveals a 404, however. And notably, the Location header in the response does not have the expected port. Am I missing something dumb?
Could it be that 8443 is your splunkweb port, rather than splunkd?
Oh. Duh. That is exactly it. Thanks.