This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

oauth token refresh
#1
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.
Reply
#2
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.
Reply
#3
(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?
Reply
#4
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.
Reply


Forum Jump: