Getting Data In

Reset token from tokens.py in splunk REST app

joseag
New Member

I need some help, I am using version 1.5.3 of the splunk Rest App, how can I reset the tokens.py ?, in the url of my endpoint
I need to change the date to the current date and configure the tockens.py of the following
way and it works, only that it works when I restart the whole environment and would like it to be according to tokens.py.

def datetoday():
today = datetime.date.today()
return today.strftime('%Y.%m.%d')

This is my original URL:
http://server:port/process.external.registerlocationupdaterequest-2019.01.07/_search?pretty

This is my URL with token added:
http://server:port/process.external.registerlocationupdaterequest-$datetoday$/_search?pretty

try adding the following class in responsehandlers.py to force the token as I saw it in the next
Dennis answer:

https://answers.splunk.com/answers/311261/rest-api-modular-input-app-tokens-not-resetting.html

it just did not work and I did not leave any error message.

class MyTokenResponseHandler:

def __init__(self,**args):
     pass

 def __call__(self, response_object,raw_response_output,response_type,req_args,endpoint):

     print_xml_stream(raw_response_output)

     today = datetime.now()
     time_fmt = '%Y.%m.%d'

     if not "params" in req_args:
     req_args["params"] = {}
     req_args["params"]["datetoday"] = today.strftime(time_fmt)

also try adding the following lines in the rest.py as it says damien.branger, but it did not work.

        original_endpoint=config.get("endpoint")
        #token replacement
        endpoint_list = replaceTokens(original_endpoint)

I already reexpress the documentation and I can not find more information, someone who could support me, I would really appreciate it.

0 Karma
Get Updates on the Splunk Community!

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...