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!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...