OAuth authentication require any additional script to fetch new Refresh token from 3rd party app?

Suresh93
Tera Guru

Hi Community,

 

Currently we are doing an outbound integration with 3rd party application using Flow designer. We have configured OAuth Client profile on the instance and have linked it to the Connection and Credential Alias which we then use it in the Rest step of the flow action.

 

Now to get the access and refresh token I understand we can use the Get OAuth Token related link on the credential profile and for every call made thereafter from ServiceNow to other system will utilize these access and refresh token for authorization. 

Also, I understand there is some lifespan/expiry for access and refresh token however, while testing we observed that after every call made from ServiceNow, the refresh token expiry gets extended

For example,

Refresh token expiry is 100 days, considering from today it will expiry on 19-01-2024

The next day when we make a call from ServiceNow to 3rd party application, we could see the refresh token expiry is extended i.e. 20-01-2024.

 

I'm new to OAuth 2.0 integration so, not sure if this is the expected behavior?

If not, do we have to write any additional script to get the new refresh token when it is expired?

 

Any advice would be really appreciated. Thanks!

 

Kind Regards

Suresh

2 ACCEPTED SOLUTIONS

Peter Bodelier
Giga Sage

Hi @Suresh93 

 

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


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

Hi @Peter Bodelier 

 

I was able to fetch the refresh and access token using the script. Thanks for providing the helpful resources!

 

Kind Regards

Suresh 

View solution in original post

3 REPLIES 3

Peter Bodelier
Giga Sage

Hi @Suresh93 

 

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


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Hi @Peter Bodelier 

 

I was able to fetch the refresh and access token using the script. Thanks for providing the helpful resources!

 

Kind Regards

Suresh 

Devi
Tera Contributor

can you please share the script to get refresh token and update it