<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using tokens in splunklib? in Security</title>
    <link>https://community.splunk.com/t5/Security/Using-tokens-in-splunklib/m-p/31053#M1034</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm writing a custom command that is supposed to do some actions on Splunk through its REST interface so I wanted to use the SDK.&lt;BR /&gt;
However, I'm having problems authenticating with the session token. Here's the setup:&lt;/P&gt;

&lt;P&gt;In commands.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mycommand]
filename = mycommand.py
generating = true
maxinputs = 1
stderr_dest = message
passauth = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The code (auth part):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client
import splunk.Intersplunk as si

settings = dict()
records = si.readResults(settings = settings, has_header = True)

sKey = settings['sessionKey']

service = client.connect(token=sKey)
a = service.apps["search"]
st = a.state()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I don't get anything back.&lt;BR /&gt;
If I change the client.connect call to use hardcoded credentials it works without any problems.&lt;BR /&gt;
In Splunk I'm logged in as admin.&lt;/P&gt;

&lt;P&gt;Any idea why I can't pass tokens like this to the Service class?&lt;/P&gt;</description>
    <pubDate>Sat, 10 Aug 2013 21:45:33 GMT</pubDate>
    <dc:creator>bojanz</dc:creator>
    <dc:date>2013-08-10T21:45:33Z</dc:date>
    <item>
      <title>Using tokens in splunklib?</title>
      <link>https://community.splunk.com/t5/Security/Using-tokens-in-splunklib/m-p/31053#M1034</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm writing a custom command that is supposed to do some actions on Splunk through its REST interface so I wanted to use the SDK.&lt;BR /&gt;
However, I'm having problems authenticating with the session token. Here's the setup:&lt;/P&gt;

&lt;P&gt;In commands.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mycommand]
filename = mycommand.py
generating = true
maxinputs = 1
stderr_dest = message
passauth = true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The code (auth part):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client
import splunk.Intersplunk as si

settings = dict()
records = si.readResults(settings = settings, has_header = True)

sKey = settings['sessionKey']

service = client.connect(token=sKey)
a = service.apps["search"]
st = a.state()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I don't get anything back.&lt;BR /&gt;
If I change the client.connect call to use hardcoded credentials it works without any problems.&lt;BR /&gt;
In Splunk I'm logged in as admin.&lt;/P&gt;

&lt;P&gt;Any idea why I can't pass tokens like this to the Service class?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Aug 2013 21:45:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Using-tokens-in-splunklib/m-p/31053#M1034</guid>
      <dc:creator>bojanz</dc:creator>
      <dc:date>2013-08-10T21:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using tokens in splunklib?</title>
      <link>https://community.splunk.com/t5/Security/Using-tokens-in-splunklib/m-p/31054#M1035</link>
      <description>&lt;P&gt;Your configuration looks good. Assuming you've got a good session key client.connect should work. What value are you getting back from settings['sessionKey']?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2013 17:36:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Using-tokens-in-splunklib/m-p/31054#M1035</guid>
      <dc:creator>David_Noble_at_</dc:creator>
      <dc:date>2013-11-15T17:36:20Z</dc:date>
    </item>
  </channel>
</rss>

