oAuth - How to use Refresh token, access token, and refresh every 2 hours

GB14
Kilo Patron

The vendor gave us client creds, access token, and refresh token for the integration. We have added a new oauth cred using the client credentials option but we are getting "Invalid grant_type" 

 

Where can I store the access and refresh token and how can we refresh it every 2 hours?

 

Thanks,
G



1 ACCEPTED SOLUTION

SK Chand Basha
Giga Sage

Hi @GB14 

Access token and refresh token are stored in oauth_credential table. 

 

you have life span of refresh token

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0791131

 

You can run schedule job which would run  just before the Refresh token expires and regenerate the refresh token.

 

https://www.servicenow.com/community/developer-blog/rest-calls-where-seperate-auth-token-must-be-req...

 

Mark it helpful and Accept Solution!! If this helps you to understand.

View solution in original post

2 REPLIES 2

SK Chand Basha
Giga Sage

Hi @GB14 

Access token and refresh token are stored in oauth_credential table. 

 

you have life span of refresh token

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0791131

 

You can run schedule job which would run  just before the Refresh token expires and regenerate the refresh token.

 

https://www.servicenow.com/community/developer-blog/rest-calls-where-seperate-auth-token-must-be-req...

 

Mark it helpful and Accept Solution!! If this helps you to understand.

GB14
Kilo Patron

Thanks @SK Chand Basha  
2nd link was a good reference. Thanks 
We ended up creating some custom fields and storing the refresh token and access token to achieve it.