How to automatically use Oauth refresh token in outbound REST message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 06:40 AM
I've set up OAuth integration with a custom third-party OAuth provider. This part works fine. I am able to get the OAuth tokens. Then I use this OAuth integration together with an outbound REST message, and that also works fine as long as I have first obtained the OAuth tokens.
Here comes the problem, the access_token I get is only valid for 5 minutes and after that I have to repeat the "Get OAuth tokens" again to continue using the outbound REST message. I also get a refresh token that is valid for 3600 seconds. But I don't know how to use this token for anything.
Is it possible to automatically use the refresh token to obtain a new valid access token if the outbound REST message discovers that the access token is no longer valid? Or can I create a cron job that refreshes the access token automatically every 5 minutes? Or does someone have suggestions of other ways of solving this? Unfortunately I can't do anything about the 5 minute validity window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2020 06:54 AM
You can use script to obtain the refresh and access token from script
refer below links
How to Setup OAuth2 authentication for outbound RESTMessageV2 integrations
OAuth : Script to Automate Token Request
How to generate the access token once it is expired from Business Rule?
How to get Auth Token using script when grant type is Authorization code
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 12:10 AM