Posts: 212
Threads: 61
Joined: May 2018
Reputation:
4
Thanks, it works.
What would be the best way if i wanted the connection to the API to stay active, and then run seperate scripts for various commands?
It's not best practise to request new tokens for every command.
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Create a scheduled script that will call GetToken() periodically and save the token into storage. All other scripts will use this token to make requests.
Check the expiresIn field that /api/accounts/token returns. It will tell for how many seconds the token is valid. Adjust scheduled script execution period accordingly.
Posts: 133
Threads: 28
Joined: May 2016
Reputation:
3
that would be very nice and would save me a lot of time :-)
Posts: 212
Threads: 61
Joined: May 2018
Reputation:
4
Works like a charm. I'll post when I have access to my LM again.