<?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 connect to splunk instance using custom endpoints in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/connect-to-splunk-instance-using-custom-endpoints/m-p/456661#M8303</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I have developed few mashup API (combining two or more KVStore into single API) for our app in python language. everything works perfectly fine but I have used hardcoded password to connect Splunk instance, here is my code snippet.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            USERNAME = "admin"
            PASSWORD = "changeme"

            opts.kwargs["port"] = listening_port
            opts.kwargs["host"] = src_ip
            opts.kwargs["app"] = APPNAME
            opts.kwargs["token"] = system_authtoken
            opts.kwargs["username"] = USERNAME
            opts.kwargs["password"] = PASSWORD
            opts.kwargs["owner"] = 'nobody'
            self.service = connect(**opts.kwargs)
            logger.debug('[ServiceHandle] user=%s service=%s' % (user, self.service)) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to remove these hard-coded username and password and use same username/password user logged in&lt;/P&gt;

&lt;P&gt;can you please help me how do I do this?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;NOTE&lt;/EM&gt;&lt;/STRONG&gt;: I am not using any custom command and my all endpoints are mentioned in &lt;STRONG&gt;restmap.conf&lt;/STRONG&gt; and &lt;STRONG&gt;web.conf&lt;/STRONG&gt;  &lt;/P&gt;</description>
    <pubDate>Tue, 24 Jul 2018 16:03:51 GMT</pubDate>
    <dc:creator>jangid</dc:creator>
    <dc:date>2018-07-24T16:03:51Z</dc:date>
    <item>
      <title>connect to splunk instance using custom endpoints</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/connect-to-splunk-instance-using-custom-endpoints/m-p/456661#M8303</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I have developed few mashup API (combining two or more KVStore into single API) for our app in python language. everything works perfectly fine but I have used hardcoded password to connect Splunk instance, here is my code snippet.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            USERNAME = "admin"
            PASSWORD = "changeme"

            opts.kwargs["port"] = listening_port
            opts.kwargs["host"] = src_ip
            opts.kwargs["app"] = APPNAME
            opts.kwargs["token"] = system_authtoken
            opts.kwargs["username"] = USERNAME
            opts.kwargs["password"] = PASSWORD
            opts.kwargs["owner"] = 'nobody'
            self.service = connect(**opts.kwargs)
            logger.debug('[ServiceHandle] user=%s service=%s' % (user, self.service)) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to remove these hard-coded username and password and use same username/password user logged in&lt;/P&gt;

&lt;P&gt;can you please help me how do I do this?&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;NOTE&lt;/EM&gt;&lt;/STRONG&gt;: I am not using any custom command and my all endpoints are mentioned in &lt;STRONG&gt;restmap.conf&lt;/STRONG&gt; and &lt;STRONG&gt;web.conf&lt;/STRONG&gt;  &lt;/P&gt;</description>
      <pubDate>Tue, 24 Jul 2018 16:03:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/connect-to-splunk-instance-using-custom-endpoints/m-p/456661#M8303</guid>
      <dc:creator>jangid</dc:creator>
      <dc:date>2018-07-24T16:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: connect to splunk instance using custom endpoints</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/connect-to-splunk-instance-using-custom-endpoints/m-p/456662#M8304</link>
      <description>&lt;P&gt;There is no way to connect Splunk service without username and password. for my specific requirement I have used setup page where I am storing the username and password and reading username password before connect method.&lt;/P&gt;

&lt;P&gt;e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;username, password = getUsernamePassword(sessionKey)


def getUsernamePassword(sessionKey):
    setup_entity = entity.getEntity('setup', 'manoj', namespace=appname, owner='nobody', sessionKey=sessionKey)
    for each in setup_entity:
        if each == 'username':
            username = setup_entity[each]
        elif each == 'password':
            password = setup_entity[each]
    return username, password
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Sep 2018 13:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/connect-to-splunk-instance-using-custom-endpoints/m-p/456662#M8304</guid>
      <dc:creator>jangid</dc:creator>
      <dc:date>2018-09-05T13:06:36Z</dc:date>
    </item>
  </channel>
</rss>

