<?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: REST API Modular Input - 401 Client Unauthorized in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371185#M67404</link>
    <description>&lt;P&gt;Awesome. Many thanks indeed for all your help on this one!&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 20:58:08 GMT</pubDate>
    <dc:creator>hpintelliflo</dc:creator>
    <dc:date>2017-10-10T20:58:08Z</dc:date>
    <item>
      <title>REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371175#M67394</link>
      <description>&lt;P&gt;I'm trying to get the REST Input to work with Google Nest API which has a space in one of the headers which I think is causing an issue. I can get other REST APIs to work on the same server. The header is the Authorization one which includes Bearer and then a key&lt;/P&gt;

&lt;P&gt;From postman I can get to the Nest API from the server so it's not a network issue.&lt;/P&gt;

&lt;P&gt;But splunkd.log is giving me &lt;/P&gt;

&lt;P&gt;09-29-2017 15:10:52.452 +0000 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\rest_ta\bin\rest.py"" HTTP Request error: 401 Client Error: Unauthorized&lt;/P&gt;

&lt;P&gt;I’ve tried putting inverted commas around it but that hasn’t fixed it. I have also tried replacing the space with %20&lt;/P&gt;

&lt;P&gt;The inputs.conf stanza is &lt;/P&gt;

&lt;P&gt;[rest://Nest]&lt;BR /&gt;
auth_type = none&lt;BR /&gt;
endpoint = &lt;A href="https://developer-api.nest.com/" target="_blank"&gt;https://developer-api.nest.com/&lt;/A&gt;&lt;BR /&gt;
http_header_propertys = Authorization=Bearer c.hp9b{rest of key}&lt;BR /&gt;
http_method = GET&lt;BR /&gt;
index = nest&lt;BR /&gt;
index_error_response_codes = 0&lt;BR /&gt;
response_type = json&lt;BR /&gt;
sequential_mode = 0&lt;BR /&gt;
sourcetype = _json&lt;BR /&gt;
streaming_request = 0&lt;BR /&gt;
disabled = 0&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:03:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371175#M67394</guid>
      <dc:creator>hpintelliflo</dc:creator>
      <dc:date>2020-09-29T16:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371176#M67395</link>
      <description>&lt;P&gt;Some of the code examples dont have the "c." part , what happens if you remove that ?&lt;/P&gt;

&lt;P&gt;Also try adding in the  &lt;CODE&gt;Content-Type=application/json&lt;/CODE&gt;  header also as per the examples in the docs&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 01:11:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371176#M67395</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2017-10-01T01:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371177#M67396</link>
      <description>&lt;P&gt;Thanks Damien.  Will try. I’ve confirmed wih postman that the content type header isn’t required. &lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 01:17:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371177#M67396</guid>
      <dc:creator>hpintelliflo</dc:creator>
      <dc:date>2017-10-01T01:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371178#M67397</link>
      <description>&lt;P&gt;I can't really see anything else based of that inputs.conf snippet.&lt;BR /&gt;
Maybe ensure that there is no hidden whitespace after your token and/or put in the content type header anyway as is in the Python 2.7 examples on the docs site.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 01:34:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371178#M67397</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2017-10-01T01:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371179#M67398</link>
      <description>&lt;P&gt;This reminds me of a BBQ temperature sensor I helped integrate with Splunk a year or two ago.  In the end we found the temp sensors API wanted the Authorization token in the headers to be lowercase authorization.  Not sure how to hack that into the rest_ta, but it's worth a shot in postman to see if you can replicate it.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Oct 2017 12:22:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371179#M67398</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-10-01T12:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371180#M67399</link>
      <description>&lt;P&gt;Guys I've tried all of these but nothing has worked ... any more ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 22:47:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371180#M67399</guid>
      <dc:creator>hpintelliflo</dc:creator>
      <dc:date>2017-10-09T22:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371181#M67400</link>
      <description>&lt;P&gt;Can you compare the HTTP POST/GET data you see on the actual wire with a successful request vs a non successful request.This should tell you exactly what , if any,  differences there may be at the client end ie: using ngrep, wireshark , tcpdump .. or maybe even Splunk Stream &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Some examples here of using ngrep and tcpdump : &lt;A href="https://stackoverflow.com/questions/9241391/how-to-capture-all-the-http-packets-using-tcpdump"&gt;https://stackoverflow.com/questions/9241391/how-to-capture-all-the-http-packets-using-tcpdump&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 23:05:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371181#M67400</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2017-10-09T23:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371182#M67401</link>
      <description>&lt;P&gt;I’ll second this approach &lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 23:17:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371182#M67401</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-10-09T23:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371183#M67402</link>
      <description>&lt;P&gt;Guys - i think i have worked it out ... Nest does a 307 redirect. I suspect the module is not sending the headers on the redirect request. This Python is working&lt;/P&gt;

&lt;P&gt;import httplib&lt;/P&gt;

&lt;P&gt;headers = {"Authorization": "Bearer c.{INSERT KEY}"}&lt;/P&gt;

&lt;P&gt;conn = httplib.HTTPSConnection("developer-api.nest.com")&lt;BR /&gt;
conn.request("GET", "/", "", headers)&lt;BR /&gt;
response = conn.getresponse()&lt;/P&gt;

&lt;P&gt;url2 = response.getheader("location")&lt;BR /&gt;
url2 = url2[8:-1]&lt;/P&gt;

&lt;P&gt;conn2 = httplib.HTTPSConnection(url2)&lt;BR /&gt;
conn2.request("GET", "/", "", headers)&lt;BR /&gt;
response2 = conn2.getresponse()&lt;/P&gt;

&lt;P&gt;print response2.read()&lt;BR /&gt;
conn.close()&lt;BR /&gt;
conn2.close()&lt;/P&gt;

&lt;P&gt;Any thoughts?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 15:37:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371183#M67402</guid>
      <dc:creator>hpintelliflo</dc:creator>
      <dc:date>2017-10-10T15:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371184#M67403</link>
      <description>&lt;P&gt;You need to add a custom response handler in &lt;CODE&gt;rest_ta/bin/responsehandlers.py&lt;/CODE&gt; and declare this handler to be applied in your stanza setup.&lt;/P&gt;

&lt;P&gt;This custom handler would process the response from request 1 , get the the url from the location header for request 2 and send off request 2.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 20:38:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371184#M67403</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2017-10-10T20:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: REST API Modular Input - 401 Client Unauthorized</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371185#M67404</link>
      <description>&lt;P&gt;Awesome. Many thanks indeed for all your help on this one!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 20:58:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/REST-API-Modular-Input-401-Client-Unauthorized/m-p/371185#M67404</guid>
      <dc:creator>hpintelliflo</dc:creator>
      <dc:date>2017-10-10T20:58:08Z</dc:date>
    </item>
  </channel>
</rss>

