<?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 Is it possible to use a token for Java SDK? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Is-it-possible-to-use-a-token-for-Java-SDK/m-p/509685#M33958</link>
    <description>&lt;P&gt;I have an authentication token which I have found success using curls and the REST API.&lt;/P&gt;&lt;P&gt;I'm trying to drop limited log events from a Java application in AWS.&lt;BR /&gt;All of the documentation that I can find discusses using username and password with the Java SDK client.&lt;BR /&gt;But I only have HEC token and endpoint.&lt;/P&gt;&lt;PRE&gt;It's working perfectly fine on my test Splunk.&lt;BR /&gt; service = &lt;SPAN&gt;new &lt;/SPAN&gt;Service(&lt;SPAN&gt;"HOST"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;Port&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; String credentials = &lt;SPAN&gt;"Username:Password"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; String basicAuthHeader = Base64.encode(credentials.getBytes());&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; service.setToken("Basic " + basicAuthHeader);&lt;BR /&gt;&lt;BR /&gt;But i don't have username and password for production Splunk, have only HEC endpoint and token.&lt;BR /&gt;So when I am trying to do &lt;BR /&gt;&lt;BR /&gt;service = new Service("HOST",Port);&lt;BR /&gt;service.setToken("MY HEC TOKEN");&lt;BR /&gt;&lt;BR /&gt;I am getting UnAuthorized Exception&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Is there any way to use Java SDK w/o username and password.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jul 2020 11:53:11 GMT</pubDate>
    <dc:creator>akshgpt25</dc:creator>
    <dc:date>2020-07-17T11:53:11Z</dc:date>
    <item>
      <title>Is it possible to use a token for Java SDK?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Is-it-possible-to-use-a-token-for-Java-SDK/m-p/509685#M33958</link>
      <description>&lt;P&gt;I have an authentication token which I have found success using curls and the REST API.&lt;/P&gt;&lt;P&gt;I'm trying to drop limited log events from a Java application in AWS.&lt;BR /&gt;All of the documentation that I can find discusses using username and password with the Java SDK client.&lt;BR /&gt;But I only have HEC token and endpoint.&lt;/P&gt;&lt;PRE&gt;It's working perfectly fine on my test Splunk.&lt;BR /&gt; service = &lt;SPAN&gt;new &lt;/SPAN&gt;Service(&lt;SPAN&gt;"HOST"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;Port&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt; String credentials = &lt;SPAN&gt;"Username:Password"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; String basicAuthHeader = Base64.encode(credentials.getBytes());&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt; service.setToken("Basic " + basicAuthHeader);&lt;BR /&gt;&lt;BR /&gt;But i don't have username and password for production Splunk, have only HEC endpoint and token.&lt;BR /&gt;So when I am trying to do &lt;BR /&gt;&lt;BR /&gt;service = new Service("HOST",Port);&lt;BR /&gt;service.setToken("MY HEC TOKEN");&lt;BR /&gt;&lt;BR /&gt;I am getting UnAuthorized Exception&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Is there any way to use Java SDK w/o username and password.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 11:53:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Is-it-possible-to-use-a-token-for-Java-SDK/m-p/509685#M33958</guid>
      <dc:creator>akshgpt25</dc:creator>
      <dc:date>2020-07-17T11:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use a token for Java SDK?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Is-it-possible-to-use-a-token-for-Java-SDK/m-p/509688#M33959</link>
      <description>&lt;P&gt;Set the Authentication header to "&lt;FONT face="courier new,courier"&gt;Splunk &amp;lt;token&amp;gt;&lt;/FONT&gt;".&amp;nbsp; You'll also need to make sure to use the HEC URI and port.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 12:49:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Is-it-possible-to-use-a-token-for-Java-SDK/m-p/509688#M33959</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-07-17T12:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use a token for Java SDK?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Is-it-possible-to-use-a-token-for-Java-SDK/m-p/509952#M33996</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I am trying that below exception is coming&lt;/P&gt;&lt;P&gt;Exception in thread "main" com.splunk.HttpException: HTTP 404 -- {"text":"The requested URL was not found on this server.","code":404}&lt;BR /&gt;at com.splunk.HttpException.create(HttpException.java:84)&lt;BR /&gt;at com.splunk.HttpService.send(HttpService.java:500)&lt;BR /&gt;at com.splunk.Service.send(Service.java:1295)&lt;/P&gt;&lt;P&gt;My Code&lt;/P&gt;&lt;PRE&gt;service = &lt;SPAN&gt;new &lt;/SPAN&gt;Service(&lt;SPAN&gt;"XX.XX.XX.XX"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;8088&lt;/SPAN&gt;)&lt;SPAN&gt;;&lt;BR /&gt;service.setToken("Splunk #TOKEN");&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Below Curl is working fine for me.&lt;/P&gt;&lt;P&gt;curl -k &lt;A href="https://10.149.60.198:8088/services/collector" target="_blank" rel="noopener"&gt;https://XX.XX.XX.XX:8088/services/collector&lt;/A&gt; -H "Authorization: Splunk #TOKEN" -d '{"event": "hello world"}'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should I use XX.XX.XX.XX/services/collector as HEC URI.&lt;SPAN&gt;&amp;nbsp;Can you also confirm whether I am using the right URI or not.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am running Splunk Enterprise on ec2 with Public IP XX.XX.XX.XX:443. and I am using XX.XX.XX.XX:8088 as HEC URI and Port. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can you please help with this as well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thanks Again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 05:27:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Is-it-possible-to-use-a-token-for-Java-SDK/m-p/509952#M33996</guid>
      <dc:creator>akshgpt25</dc:creator>
      <dc:date>2020-07-20T05:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use a token for Java SDK?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Is-it-possible-to-use-a-token-for-Java-SDK/m-p/510033#M34008</link>
      <description>&lt;P&gt;I'm not sure what service your code uses, but this seems not right&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;service.setToken("Splunk #TOKEN");&lt;/LI-CODE&gt;&lt;P&gt;The code should set an HTTP header called "Authentication" with the value "Splunk " followed by the HEC token.&amp;nbsp; It should be the Java equivalent to the curl option&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;&amp;nbsp;-H "Authorization: Splunk #TOKEN"&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;If the URL works for curl then it should work for Java as well.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 13:35:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Is-it-possible-to-use-a-token-for-Java-SDK/m-p/510033#M34008</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-07-20T13:35:43Z</dc:date>
    </item>
  </channel>
</rss>

