oauth token refresh - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: oauth token refresh (/showthread.php?tid=3957) |
oauth token refresh - benanderson_475 - 25.03.2022 Hi, What is the best way to manage Oauth tokens and refresh tokens on lm, I post the data to the endpoint and receive a refresh_token and access_token and also an expiry time, expires_in eg 10800 sec how can i make some lua code to get the get the refresh_token after expiry time in sec has lapsed Many thanks. RE: oauth token refresh - admin - 25.03.2022 Put your access and refresh tokens into storage. Create a scheduled script to handle the refresh and put updated tokens back into storage. All other scripts will use stored tokens for requests. RE: oauth token refresh - benanderson_475 - 25.03.2022 (25.03.2022, 07:30)admin Wrote: Put your access and refresh tokens into storage. Create a scheduled script to handle the refresh and put updated tokens back into storage. All other scripts will use stored tokens for requests. Thanks, how can I be approximate in expiry time, if I request the refresh token before expiry time lapses a new token is not returned, if I have a scheduled script running say every 10min to refresh tokens I might have to wait before the new token is returned and I guess it is depending on when the last call was made and when the scheduled script is due to run. I am thinking Is it possible to calculate os.time() + expire_sec and make a script run at this approximate time? RE: oauth token refresh - admin - 25.03.2022 There's no strict rule when the refresh should be executed, it can happen earlier. Just make sure that the interval between each execution is less than the token expiration time. |