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!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...