Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Will Oauth2.0 refresh token be automatically refreshed once it's about to expire?

Floor
Tera Contributor

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

1 ACCEPTED SOLUTION

Community Alums
Not applicable

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

 

View solution in original post

4 REPLIES 4

Community Alums
Not applicable

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

 

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

Aditya Sharma 7
Tera Contributor

Hi @Floor ,

 

Have you got a solution for this? Is your refresh token is getting automatically renewed after expiration date?

 

Regards,

Aditya Sharma

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