Automation of Reporter API Sales.generateToken()

Hi

I have been working with the Reporter API 2.2 outlined as per the documentation here https://help.apple.com/itc/contentreporterguide/en.lproj/static.html#itcbe21ac7db .

Everything is working fine however I've noted that the access token has an expiry of 180 days, therefore I would like to automate the process of generating new tokens every so often so that I do not have to do this manually for the number of accounts that I am handling and plethora of reports i am pulling out.

I've tried numerous methods to automate this but ultimately none has worked. The following tries result in an instant null response:

echo "user pass" | java -jar Reporter.jar p=Reporter.properties Sales.generateToken

echo "user\npass\n" | java -jar Reporter.jar p=Reporter.properties Sales.generateToken

java -jar Reporter.jar p=Reporter.properties Sales.generateToken < credentials.txt

(echo "user"; sleep 1; echo "pass") | java -jar Reporter.jar p=Reporter.properties Sales.generateToken

So directly piping does not work. I also wrote a shell script using spawn expect send workflow, although it looks like the prompts are being answered in order, there is no output at the end:
#!/usr/bin/expect spawn java -jar Reporter.jar p=Reporter.properties Sales.generateToken expect "username"; send "user\n"; expect "password"; send "pass\n";


I also tried to write a python script to achieve the same thing but seem to be getting to the same problem. Is this not allowed? Is there a workaround or native support? To me it doesnt seem like this command takes any additional arguments.

Thanks

spawn java -jar Reporter.jar p=Reporter.properties Sales.generateToken expect "Please enter your username:" send "username\n" expect "Please enter your password:" send "password\n" expect "continue?" send "y\n"

 I've found this: https://github.com/fedoco/itc-reporter, a python based solution. Did you find a solution? Mind sharing? TIA

Automation of Reporter API Sales.generateToken()
 
 
Q