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!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...