Scheduled job to automatically get new Oauth token/refresh token when old one expires

Andrei Radules1
Giga Contributor

Hello,

I currently have 2 ServiceNow Instances synced between each other using OAuth 2.

Currently, when the token expires I have to manually get a new one from the REST message.

I am trying to create a new Scheduled job to run just before the refresh token expires so I can create a new one automatically without any manual input.

Can someone advise how the scheduled job script will look so that it checks for an expiry date of the current token and then automatically requests and updates the new token?

Thank you!

 

6 REPLIES 6

Andrei Radules1
Giga Contributor

I am trying to not include the token request directly in the  business rules