- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 07:20 AM
Hi there,
I got a question about the refresh token when using Oauth2.0.
I got it working, when I click the 'get Oauth token' link (and fill in username + password) i'm getting the oauth tokens in the Manage token table.
1 access token (expires in 1 hour) and 1 refresh token (expires in 1 month).
Now my question is: what will happen if the refresh token will expire after a month?
Will Servicenow automatically generate a new one for me? Or do I need to retrieve this myself with a scripted scheduled job or something?
It's hard to test because I don't have a month to wait for the refresh token to expire hihi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 07:30 AM
Hi @Floor ,
By default, access token and refresh token are stored in oauth_credential table.
You can run schedule job which would run Yearly just before the Refresh token expires and regenerate the refresh token.
script to be used :
Script to retrieve Access and Refresh tokens using GlideOAuthClient libraries
Also, refer to the article:
https://community.servicenow.com/community?id=community_blog&sys_id=d547f492db61d300fc5b7a9e0f9619d2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2023 07:30 AM
Hi @Floor ,
By default, access token and refresh token are stored in oauth_credential table.
You can run schedule job which would run Yearly just before the Refresh token expires and regenerate the refresh token.
script to be used :
Script to retrieve Access and Refresh tokens using GlideOAuthClient libraries
Also, refer to the article:
https://community.servicenow.com/community?id=community_blog&sys_id=d547f492db61d300fc5b7a9e0f9619d2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 01:47 AM
Hi @Community Alums ,
Will the access token be re-generated automatically by system without writing any scheduled job or script or do we have to write a script ?
Regards,
Ansh Mahajan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 05:12 AM
Hi @Floor ,
Have you got a solution for this? Is your refresh token is getting automatically renewed after expiration date?
Regards,
Aditya Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2023 05:35 AM
Hi @Aditya Sharma 7,
Yes like Sandeep said we created a scheduled job for this and for another interface a business rule (no refresh token).
See for script: Script to retrieve Access and Refresh tokens using GlideOAuthClient libraries
Regards,
Floor