<?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: Setup.xml: Is there a way to get the current session key in custom endpoint? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Setup-xml-Is-there-a-way-to-get-the-current-session-key-in/m-p/589538#M3093</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/2044"&gt;@phoenixdigital&lt;/a&gt;&amp;nbsp;what is the "self" object you are referring to here? I'm having issues getting session key in a scripted input running on windows, but it works in linux environments.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regarss&lt;/P&gt;</description>
    <pubDate>Thu, 17 Mar 2022 15:03:14 GMT</pubDate>
    <dc:creator>christoffertoft</dc:creator>
    <dc:date>2022-03-17T15:03:14Z</dc:date>
    <item>
      <title>Setup.xml: Is there a way to get the current session key in custom endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Setup-xml-Is-there-a-way-to-get-the-current-session-key-in/m-p/246509#M3091</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Working from this example&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/webframework-developapps/SP-CAAAE9B" target="_blank"&gt;http://dev.splunk.com/view/webframework-developapps/SP-CAAAE9B&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Is there any way to get the current session key in the custom endpoint MyApp_python_handler.py&lt;/P&gt;

&lt;P&gt;I need to perform some calls against the REST interface and don't want to have to hardcode Splunk usernames and passwords in the python script.&lt;/P&gt;

&lt;P&gt;I've tried&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;config_str = sys.stdin.read()
doc = xml.dom.minidom.parseString(config_str)
root = doc.documentElement
session_key = root.getElementsByTagName("sessionKey")[0].firstChild.data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And it throws an error&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ERROR AdminManagerExternal - &amp;lt;class 'splunk.admin.UsageException'&amp;gt;: Received no serialized data via stdin (mode: setup). Will not continue.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However even though it throws that error it is pulling in the session key because I can see it by adding a print at the end&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;config_str = sys.stdin.read()
doc = xml.dom.minidom.parseString(config_str)
root = doc.documentElement
session_key = root.getElementsByTagName("sessionKey")[0].firstChild.data
print("type=readStdIn,session_key=%s" % session_key)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Error in splunkd which is to be expected because I shouldn't be printing this out. I tried using logging.info but that doesn't show up in logs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;01-19-2017 13:11:13.762 +1000 ERROR AdminManagerExternal - Unable to xml-parse the following data: %stype=readStdIn,session_key=jW3neEYMJ29lzdDyPm0OVW6g5XmTR_tVd0jErcj^T3cuEASlQAfs5F2xhFw_k3TMTwqF3uyYZTNQ2L9PLUYFRvYnnHYqqB9oeUP^zQ...  See splunkd.log for full data.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:29:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Setup-xml-Is-there-a-way-to-get-the-current-session-key-in/m-p/246509#M3091</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2020-09-29T12:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Setup.xml: Is there a way to get the current session key in custom endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Setup-xml-Is-there-a-way-to-get-the-current-session-key-in/m-p/246510#M3092</link>
      <description>&lt;P&gt;I may have found it&lt;/P&gt;

&lt;P&gt;self.getSessionKey()&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 03:23:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Setup-xml-Is-there-a-way-to-get-the-current-session-key-in/m-p/246510#M3092</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2017-01-19T03:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Setup.xml: Is there a way to get the current session key in custom endpoint?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Setup-xml-Is-there-a-way-to-get-the-current-session-key-in/m-p/589538#M3093</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/2044"&gt;@phoenixdigital&lt;/a&gt;&amp;nbsp;what is the "self" object you are referring to here? I'm having issues getting session key in a scripted input running on windows, but it works in linux environments.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regarss&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 15:03:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Setup-xml-Is-there-a-way-to-get-the-current-session-key-in/m-p/589538#M3093</guid>
      <dc:creator>christoffertoft</dc:creator>
      <dc:date>2022-03-17T15:03:14Z</dc:date>
    </item>
  </channel>
</rss>

