Issue with Auto Refresh Token
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 05:37 AM
Hi All,
We are performing an integration using a Spoke in ServiceNow and have configured the oauth_2_0_credentials table to store the OAuth 2.0 credentials. The initial access token was successfully generated, and we set the refresh token lifespan to 8,640,000 seconds in the Application Registry.
However, we are encountering an issue:
Before the access token's expected expiry time, the integration fails in Flow Designer with an authentication error. Once we manually refresh the token, the flow starts working again as expected. Can you please help us.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 05:43 AM
So you generate fresh access token each time using script and then pass that token to Flow step in actual API call
refer below links on how to get token from script
OAuth2.0: Get new Access Token from existing Refresh Token
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
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 10:22 PM
Hi @Ankur Bawiskar ,
Could you please help me understand why my access token is not working even though it hasn't yet reached its expiry date?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 10:26 PM
refresh token has long expiration, access token has usually 30mins.
It's already recommended to generate the access token using script before consuming the actual endpoint although you are calling the actual endpoint multiple times in 30mins and the access token will be the same for that 30mins.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader