Splunk Dev

API Login not working - Splunk 6. 4 Free

pinVie
Path Finder

Hi all,

I am not sure why this python code is not working:

import splunklib.client as client

service = client.connect(
    host="192.168.2.125",
    port=8089)

All I get is the following trace

Traceback (most recent call last):
  File "C:/Users/Name/Desktop/test/splunk/splkTest.py", line 13, in <module>
    port=8089)
  File "C:\Python27\lib\site-packages\splunk_sdk-1.6.0-py2.7.egg\splunklib\client.py", line 321, in connect
    s.login()
  File "C:\Python27\lib\site-packages\splunk_sdk-1.6.0-py2.7.egg\splunklib\binding.py", line 865, in login
    raise AuthenticationError("Login failed.", he)
splunklib.binding.AuthenticationError: Login failed.

I even tried to define username="admin" in the login but the effect is the same.
Is this a limitation of the splunk free version (6.4.1) or I am doing it wrong?

Thank you !

0 Karma
1 Solution

ChrisG
Splunk Employee
Splunk Employee

Generally speaking, Splunk Free doesn't have authentication. See About Splunk Free in the Admin Manual.

But see jkat54's comment, immediately below.

View solution in original post

0 Karma

ChrisG
Splunk Employee
Splunk Employee

Generally speaking, Splunk Free doesn't have authentication. See About Splunk Free in the Admin Manual.

But see jkat54's comment, immediately below.

0 Karma

jkat54
SplunkTrust
SplunkTrust

https://answers.splunk.com/answers/43809/does-splunk-free-license-allow-usage-of-rest-api.html

This seems to suggest it will support the API and login will not be required... there's just a small step of setting something in server.conf.

ChrisG
Splunk Employee
Splunk Employee

Innnnteresting. TIL. 🙂

0 Karma

pinVie
Path Finder

Ah damn it I knew this page but had a mistake in my code.
So the login is working - code has to look like this in python

service = client.connect(
    host="192.168.2.125",
    port=8089,
    username="admin")

Thank you

0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...