<?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 JS SDK: Splunk API successfully authenticates but rejects any subsequent requests with 401 Unauthorized error in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/JS-SDK-Splunk-API-successfully-authenticates-but-rejects-any/m-p/458749#M8359</link>
    <description>&lt;P&gt;It seems like I'm able to successfully establish connection with the Splunk (Enterprise) API since I'm able to successfully authenticate and retrieve a sessionKey using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var http = new splunkjs.SplunkWebHttp()

var service = new splunkjs.Service(http, {
  scheme: 'https',
  host: '&amp;lt;splunk-web-address&amp;gt;',
  port: 8089,
  username: '&amp;lt;username&amp;gt;',
  password: prompt('password'),
  version: '6.6.3'
})

service.apps().fetch((err, apps) =&amp;gt; {
  console.log(err)
  console.log(apps)
})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The last statement to retrieve and log the apps fails with the following (note that the first login call on the left was successful as the auth token was put in the request header of the  &lt;CODE&gt;/services/apps&lt;/CODE&gt; request by the SDK):&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Splunk API requests"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5435i93B9D9CD2A0A1F3D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Splunk API requests" alt="Splunk API requests" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The response is just:  &lt;CODE&gt;{"messages":[{"type":"ERROR","text":"Unauthorized"}]}&lt;/CODE&gt; My user has a role with all the  &lt;CODE&gt;rest-*&lt;/CODE&gt; capabilities, so I'm stumped. Any suggestions appreciated.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Jul 2018 08:13:26 GMT</pubDate>
    <dc:creator>akhandelwal_hf</dc:creator>
    <dc:date>2018-07-27T08:13:26Z</dc:date>
    <item>
      <title>JS SDK: Splunk API successfully authenticates but rejects any subsequent requests with 401 Unauthorized error</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/JS-SDK-Splunk-API-successfully-authenticates-but-rejects-any/m-p/458749#M8359</link>
      <description>&lt;P&gt;It seems like I'm able to successfully establish connection with the Splunk (Enterprise) API since I'm able to successfully authenticate and retrieve a sessionKey using:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var http = new splunkjs.SplunkWebHttp()

var service = new splunkjs.Service(http, {
  scheme: 'https',
  host: '&amp;lt;splunk-web-address&amp;gt;',
  port: 8089,
  username: '&amp;lt;username&amp;gt;',
  password: prompt('password'),
  version: '6.6.3'
})

service.apps().fetch((err, apps) =&amp;gt; {
  console.log(err)
  console.log(apps)
})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The last statement to retrieve and log the apps fails with the following (note that the first login call on the left was successful as the auth token was put in the request header of the  &lt;CODE&gt;/services/apps&lt;/CODE&gt; request by the SDK):&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Splunk API requests"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/5435i93B9D9CD2A0A1F3D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Splunk API requests" alt="Splunk API requests" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The response is just:  &lt;CODE&gt;{"messages":[{"type":"ERROR","text":"Unauthorized"}]}&lt;/CODE&gt; My user has a role with all the  &lt;CODE&gt;rest-*&lt;/CODE&gt; capabilities, so I'm stumped. Any suggestions appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2018 08:13:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/JS-SDK-Splunk-API-successfully-authenticates-but-rejects-any/m-p/458749#M8359</guid>
      <dc:creator>akhandelwal_hf</dc:creator>
      <dc:date>2018-07-27T08:13:26Z</dc:date>
    </item>
  </channel>
</rss>

