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 Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...