How to update Refresh token automatically once it expires in oauth2

faizu
Tera Contributor

I have an integration that uses Oauth2 as authorization which uses 2 tokens, Refresh and access token.

Access token are being taken care via code and updated automatically.

In case of refresh token there is no way to update it automatically. 

I provided life time to 1 year for refresh token but the question is how to take care of it once it is about to expire.

Any suggestions to take care of it automatically?

7 REPLIES 7

@faizu 

refresh token is used to regenerate new Access token when the older Access token expires.

If you are getting access token and refresh token in actual API call then no need to generate them again as before every actual API call you will get those and those will be the latest

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Kajal Goti
Mega Guru

Hi,

 

When you generate the token, You also get the expired duration in response accordingly you can refresh the token in a scheduled job and hit the API from where you are getting token

 

In my case we are generating token every 55 Mins where we have scheduled job which running every 55 Mins before token expired

 

 

Please mark as correct/helpful, If you find any help

Hardik10
Tera Expert

Hi,

Could you please share the script required in the scheduled job?