<?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 Re: Why am I not getting sessionKey while using custom search command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189181#M187136</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
Did you find any solution, I am facing same issue&lt;/P&gt;</description>
    <pubDate>Tue, 29 May 2018 10:09:56 GMT</pubDate>
    <dc:creator>mkhan_splunk</dc:creator>
    <dc:date>2018-05-29T10:09:56Z</dc:date>
    <item>
      <title>Why am I not getting sessionKey while using custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189179#M187134</link>
      <description>&lt;P&gt;I am having two apps, Main app and Add-On app.&lt;/P&gt;

&lt;P&gt;Add-On app contains one data collector script which works as splunk data input script and feeds  data to splunk.&lt;/P&gt;

&lt;P&gt;This data collector script  is being executed at regular intervals and each time it gets sessionkey from splunk and uses it to fetch the encrypted credentials.&lt;/P&gt;

&lt;P&gt;I have also added Custom search command in main app, there is one wrapper script for custom search command in main app, which will collect command and options and pass it to the data collector script of Add-On app.&lt;/P&gt;

&lt;P&gt;But, whenever data collector script is being called by this wrapper, it is not able to get the sessionKey from splunk.&lt;/P&gt;

&lt;P&gt;Below are the contents of commands.conf for custom search command.&lt;/P&gt;

&lt;P&gt;[customCollect]&lt;/P&gt;

&lt;P&gt;filename = customCollect.py&lt;/P&gt;

&lt;P&gt;supports_getinfo=true&lt;/P&gt;

&lt;P&gt;generating=true&lt;/P&gt;

&lt;P&gt;supports_rawargs = true&lt;/P&gt;

&lt;P&gt;outputheader = true&lt;/P&gt;

&lt;P&gt;enableheader = true&lt;/P&gt;

&lt;P&gt;passauth = true&lt;/P&gt;

&lt;P&gt;streaming = false&lt;/P&gt;

&lt;P&gt;retainsevents = true&lt;/P&gt;

&lt;P&gt;changes_colorder = true&lt;/P&gt;

&lt;P&gt;overrides_timeorder = false&lt;/P&gt;

&lt;P&gt;In data collector script, I have tried below given two approaches to get sessionkey but none of them is working.&lt;/P&gt;

&lt;P&gt;1)   results,dummyresults,settings = splunk.Intersplunk.getOrganizedResults()&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   sessionKey = settings.get("sessionKey", None)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2)   sessionKey = sys.stdin.readline().strip()&lt;/P&gt;</description>
      <pubDate>Thu, 30 Oct 2014 10:48:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189179#M187134</guid>
      <dc:creator>pjvarjani</dc:creator>
      <dc:date>2014-10-30T10:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting sessionKey while using custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189180#M187135</link>
      <description>&lt;P&gt;I have been able to get the sessionKey by doing this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunk.auth as auth

sessionKey = auth.getSessionKey('admin','&amp;lt;password for admin&amp;gt;')
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It may help in your troubleshooting, but if you have to hard code the admin credentials to get access to other credentials, what is the point...  This is very frustrating because it seems that the behavior may have changed from Splunk v4 -&amp;gt; Splunk v6.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 23:48:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189180#M187135</guid>
      <dc:creator>TonyLeeVT</dc:creator>
      <dc:date>2017-04-06T23:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting sessionKey while using custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189181#M187136</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Did you find any solution, I am facing same issue&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 10:09:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189181#M187136</guid>
      <dc:creator>mkhan_splunk</dc:creator>
      <dc:date>2018-05-29T10:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting sessionKey while using custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189182#M187137</link>
      <description>&lt;P&gt;Hi mkhab_splunk did you find any solution. I'm facing same problem&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 20:15:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189182#M187137</guid>
      <dc:creator>marcolesh</dc:creator>
      <dc:date>2018-08-16T20:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting sessionKey while using custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189183#M187138</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;import urllib2
import urllib
import httplib2

myhttp = httplib2.Http(disable_ssl_certificate_validation=True)
baseurl = 'https://127.0.0.1:8089'

searchjob = self.myhttp.request(self.baseurl + '/services/search/jobs','POST', headers={'Authorization': 'Splunk %s' % self._metadata.searchinfo.session_key},body=urllib.urlencode({'search': searchquery}))[1]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Using the code above you can get logged in splunkd using token session of logged user&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 17:25:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189183#M187138</guid>
      <dc:creator>marcolesh</dc:creator>
      <dc:date>2018-08-21T17:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting sessionKey while using custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189184#M187139</link>
      <description>&lt;P&gt;See &lt;A href="https://answers.splunk.com/answers/434017/how-to-get-session-key-in-a-search-script-script-s"&gt;https://answers.splunk.com/answers/434017/how-to-get-session-key-in-a-search-script-script-s&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I successfully implemented the approach specified in the Accepted Answer and was able to get the sessionKey when executing a custom search command.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 04:49:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/189184#M187139</guid>
      <dc:creator>tpeveler_splunk</dc:creator>
      <dc:date>2019-02-05T04:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why am I not getting sessionKey while using custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/529528#M187140</link>
      <description>&lt;P&gt;Did you ever manage to get a solution to this? I can also get the sessionKey with&amp;nbsp;&lt;/P&gt;&lt;P&gt;auth.getSessionKey('admin','&amp;lt;password for admin&amp;gt;')&lt;/P&gt;&lt;P&gt;but I also don't want to hardcode the password.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2020 12:46:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-am-I-not-getting-sessionKey-while-using-custom-search/m-p/529528#M187140</guid>
      <dc:creator>BernardEAI</dc:creator>
      <dc:date>2020-11-16T12:46:27Z</dc:date>
    </item>
  </channel>
</rss>

