- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
because it took me a while to figure out, I'll post the question and give the answer myself...
Using the documentation I did not figure out how I can connect to Splunk using a session key (eg. passed from a python script via passAuth).
The documentation is showing an example using the Service.login(...)
and the Service.setToken(String token)
method, the latter was used for a base64 encripted username:password
token.
answer will follow in a second...
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it's simple as this 😉
Service.setToken("Splunk sessionKey")
btw:
in the example: http://dev.splunk.com/view/java-sdk/SP-CAAAECX you're using com.sun.org.apache.xerces.internal.impl.dv.util.Base64
to encode the user:password
token. It is always a bad (!) idea to use code placed in class placed in a internal
package.
Use: java.util.Base64
instead.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The session key gets added in a cookie which browser uses on the subsequent search call.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to get sessionKey for particular splunk db
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
depends where you want to use it.
- in plain Java you need to login first. Service.getToken, you can use the sessionkey from you browser session, but it will expire.
- if you java code gets called from a REST endpoint (python) which extends splunk.rest.BaseRestHandler you already have it in your class (self.sessionKey).
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

can you share the piece of your code which uses the Splunk session key to connect and create/poll/consume the search !
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the sdk is quite well documented. have a look at: http://dev.splunk.com/java and the examples.
the setToken method is docmentented here: http://docs.splunk.com/DocumentationStatic/JavaSDK/1.6.4/com/splunk/ServiceArgs.html#setToken-java.l...
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Thanks. It worked
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it's simple as this 😉
Service.setToken("Splunk sessionKey")
btw:
in the example: http://dev.splunk.com/view/java-sdk/SP-CAAAECX you're using com.sun.org.apache.xerces.internal.impl.dv.util.Base64
to encode the user:password
token. It is always a bad (!) idea to use code placed in class placed in a internal
package.
Use: java.util.Base64
instead.
