How to obtain OAuth new Refresh token once it get's expired

chanikya
Mega Sage

Hi All,

Kindly help me , how to Auto get Refresh token once it's get expired. and how to get's updated under oauth_credential_list.do Table.
Here OAuth 2.0 Refresh token got expired. 

chanikya_0-1764127661164.png

Kindly let me know how to get renew refresh token.

BackGroud script side I tried below part , it is working successfully. But not Sure where to apply and how to get refresh token  , get's updated under oauth_credential_list.do Table.

var tokenRequest = new GlideOAuthClientRequest();
tokenRequest.setGrantType("password");
tokenRequest.setUserName("DEV206450");
tokenRequest.setPassword("f67[Fm>P0[e");
tokenRequest.setScope(null);

var oAuthClient = new GlideOAuthClient();
var tokenResponse = oAuthClient.requestToken("DEV206450", tokenRequest);
gs.log("Error:" + tokenResponse.getErrorMessage());

var token = tokenResponse.getToken();
if (token) {
    gs.log("AccessToken:" + token.getAccessToken());
    gs.log("AccessTokenExpiresIn:" + token.getExpiresIn());
    gs.log("RefreshToken:" + token.getRefreshToken());
}

*** Script: Error:null
*** Script: AccessToken:G_mDquRyaFsk8uJx2FpbPISZ1xB2sAKFmxJNsU4ulgBxP9-tkL077GXsiBvDbUwGK4iPM1IRxhdALEu40E0uvQ
*** Script: AccessTokenExpiresIn:299
*** Script: RefreshToken:OMYeXOqcqDNenLEORuXEqr4xKz2yIoZ2s5v0IkeCwhSVGVxRoayi4siC48ZtY__ehsVHSAJR0g6Hl1CPTHBK6Q




 

5 REPLIES 5

Hi @Ankur Bawiskar , is it the one you are asking here please 
the instance which is OAuth provider where you create OAuth registry -> there grant type is what value?
chanikya_0-1764182696503.png