<?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: How do I generate a session token that I can use in client.connect of python SDK? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328206#M4734</link>
    <description>&lt;P&gt;Thanks for the reply. I understand I can pass the credentials using the command line args but my intent was not that. What I was looking for is a way to generate a token offline and use it for client connect login (e.g., an approach similar to splunk HEC authentication token. I'm not suggesting I would use HEC token here, just referring to the concept) &lt;/P&gt;</description>
    <pubDate>Mon, 24 Jul 2017 16:21:40 GMT</pubDate>
    <dc:creator>hsingams2</dc:creator>
    <dc:date>2017-07-24T16:21:40Z</dc:date>
    <item>
      <title>How do I generate a session token that I can use in client.connect of python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328204#M4732</link>
      <description>&lt;P&gt;I'm using splunklib python SDK to connect to a splunk instance but I don't want to explicitly specify username/password in plain text in the python script. I see client.connect() function has a token argument but I am not sure how to generate this token. &lt;/P&gt;

&lt;P&gt;import splunklib.client as client&lt;BR /&gt;
service = client.connect(&lt;BR /&gt;
    host=HOST,&lt;BR /&gt;
    port=PORT,&lt;BR /&gt;
    username=USERNAME,&lt;BR /&gt;
    password=PASSWORD)&lt;/P&gt;

&lt;P&gt;What is the procedure for generating the token (i.e. session_key)?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 07:36:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328204#M4732</guid>
      <dc:creator>hsingams2</dc:creator>
      <dc:date>2017-07-24T07:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I generate a session token that I can use in client.connect of python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328205#M4733</link>
      <description>&lt;P&gt;You could pass the arguments at run time : For example...&lt;/P&gt;

&lt;P&gt;import splunklib.client as client&lt;BR /&gt;
import sys&lt;/P&gt;

&lt;P&gt;if len(sys.argv) != 5:&lt;BR /&gt;
        print "Syntax: login.py username password hostname port"&lt;BR /&gt;
        sys.exit()&lt;/P&gt;

&lt;P&gt;uid  = sys.argv[1];&lt;BR /&gt;
pwd  = sys.argv[2];&lt;BR /&gt;
host = sys.argv[3];&lt;BR /&gt;
port = sys.argv[4];&lt;/P&gt;

&lt;P&gt;try: &lt;BR /&gt;
        service = client.connect(&lt;BR /&gt;
        username=uid,&lt;BR /&gt;
        password=pwd,&lt;BR /&gt;&lt;BR /&gt;
        host=host,&lt;BR /&gt;
        port=port) &lt;BR /&gt;
        context=service.login()&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    print 'Authenticated, token = [%s]' % service.token     
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;except Exception, err:&lt;BR /&gt;
        sys.stderr.write('Error: %s\n' % str(err))&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 15:39:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328205#M4733</guid>
      <dc:creator>rroberts</dc:creator>
      <dc:date>2017-07-24T15:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I generate a session token that I can use in client.connect of python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328206#M4734</link>
      <description>&lt;P&gt;Thanks for the reply. I understand I can pass the credentials using the command line args but my intent was not that. What I was looking for is a way to generate a token offline and use it for client connect login (e.g., an approach similar to splunk HEC authentication token. I'm not suggesting I would use HEC token here, just referring to the concept) &lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 16:21:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328206#M4734</guid>
      <dc:creator>hsingams2</dc:creator>
      <dc:date>2017-07-24T16:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I generate a session token that I can use in client.connect of python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328207#M4735</link>
      <description>&lt;P&gt;If you already have a token you can use the following construct.&lt;/P&gt;

&lt;H1&gt;Or if you already have a session token&lt;/H1&gt;

&lt;P&gt;s = client.Service(token="atg232342aa34324a")&lt;BR /&gt;
Check out:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/DocumentationStatic/PythonSDK/1.5.0/client.html#splunklib.client.Service"&gt;http://docs.splunk.com/DocumentationStatic/PythonSDK/1.5.0/client.html#splunklib.client.Service&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 16:31:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328207#M4735</guid>
      <dc:creator>rroberts</dc:creator>
      <dc:date>2017-07-24T16:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I generate a session token that I can use in client.connect of python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328208#M4736</link>
      <description>&lt;P&gt;I don't have a session token and my original question is about - how do I generate one?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 18:55:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328208#M4736</guid>
      <dc:creator>hsingams2</dc:creator>
      <dc:date>2017-07-24T18:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I generate a session token that I can use in client.connect of python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328209#M4737</link>
      <description>&lt;P&gt;sounds like, the only way to generate this is by logging in with the username/password and get it from service.token &lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 19:02:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-generate-a-session-token-that-I-can-use-in-client/m-p/328209#M4737</guid>
      <dc:creator>hsingams2</dc:creator>
      <dc:date>2017-07-24T19:02:12Z</dc:date>
    </item>
  </channel>
</rss>

