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.

Checked OAuth tokens in Manage Tokens, but they dont exist anymore

D_8
Tera Contributor

Hello all,

I am trying to investigate a production support issue where I need to know the Access Tokens that were generated a week ago, for this I navigated to Manage Tokens Module. I see some Access token in this modules, but I am unable to see the access tokens that were created a week back, they dont exist at all. 

Any body knows why this is happening ?

1 ACCEPTED SOLUTION

ARG645
Tera Guru

Dustin,

Expired Tokens get cleaned up by a scheduled job.

OOB scheduled Job named Clean Expired OAuth Credentials
deletes expired Tokens of OAuth

//Delete both refresh token and authorization code that expired more than specified (default is 4) hours ago
if (gs.getProperty("com.snc.platform.security.oauth.is.active", 0)) {
gs.print('Executing Clean Expired OAuth Credentials job');
var gr = new GlideRecord('oauth_credential');
gr.addQuery('expires', '<', gs.hoursAgo(gs.getProperty("com.snc.platform.security.oauth.hours.expired.credential.is.kept", 4)));
gr.deleteMultiple();
}

Thank you,

Aman Gurram

View solution in original post

3 REPLIES 3

ARG645
Tera Guru

Dustin,

Expired Tokens get cleaned up by a scheduled job.

OOB scheduled Job named Clean Expired OAuth Credentials
deletes expired Tokens of OAuth

//Delete both refresh token and authorization code that expired more than specified (default is 4) hours ago
if (gs.getProperty("com.snc.platform.security.oauth.is.active", 0)) {
gs.print('Executing Clean Expired OAuth Credentials job');
var gr = new GlideRecord('oauth_credential');
gr.addQuery('expires', '<', gs.hoursAgo(gs.getProperty("com.snc.platform.security.oauth.hours.expired.credential.is.kept", 4)));
gr.deleteMultiple();
}

Thank you,

Aman Gurram

D_8
Tera Contributor

I see. Thank you, now its straight forward to understand why they dont exist. 

Divakar3
Kilo Contributor

Hello Amen,

 

Kindly could you help me with code to get OAuth token/refresh token manually. I found that answer in one of your reply, unfortunately I didn't find that.

Thx